Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: precmd, preexec, and supplied prompt themes



On Oct 13,  9:30am, Clint Adams wrote:
}
} >      typeset -a precmd_functions
} >      precmd_functions += my_prompt_precmd
} 
} Since there is no unregistration hook, how would you avoid the problem
} of precmd_functions containing (my_prompt_precmd her_prompt_precmd
} his_prompt_precmd my_prompt_precmd) when switching back and forth?

Well, there sort of is an unregistration hook:  prompt_off_setup
(meant to be invoked as "prompt off").

However, all it does is erase the precmd and preexec functions entirely,
which is why I added an "off" switch to my theme ("prompt bart off").

*IF* we updated the themes to be clever about precmd_functions et al.,
then the "prompt" function should be updated to call prompt_off_setup
before installing a new theme.

However, that leaves the conundrum of whether/how to unregister PS1.
"prompt bart", for example, piggybacks itself on top of whatever is
already in PS1, and "prompt bart off" extricates itself to leave PS1
mostly as it was before.

Right now "prompt off" stomps PS1 and PS2 back to the "zsh -f" default.

So some discussion of how this ought to be redesigned would be useful
before someone jumps in to do it.  It's always seemed a bit clunky to
me to do build up function names by sticking the theme name in the
middle, but that's at nit-pick.  Maybe all we need is another one of
those functions, prompt_ZZZ_off (or pick another word).

-- 



Messages sorted by: Reverse Date, Date, Thread, Author