On Mon, 16 Aug 2004, Michael Prokop wrote: > Is using 'export PROMPT' in prompt-themes reasonable? Evidently Colin Walters thought so, or whoever stole from him. It's not ideal. The prompinit wrapper saves and restores PS1 et al., but not PROMPT nor RPROMPT, when running preview. I would have expected the restoration of PS1 at exit from the function to restore PROMPT as a side-effect of their linkage, and it seems to do so when I try it, so I don't know offhand what's happening to you. The "mike@tweety ~ % " prompt doesn't look like it came from any of the zsh prompt themes I'm familiar with. Certainly not walters, which would be "mike@tweety> ", nor zefram which is always the last theme previewed. > * Is it possible to "break out" of a precmd­statement? I don't know what you're asking. > Some themes are using the precmd-option Yes, sadly, several of the themes assume you don't have anything better to do with your precmd than fiddle with the prompt. You'll note the "bart" theme goes to some lengths to avoid wrecking any existing precmd function. > e.g. prompt_adam1_setup sets the prompt via the precmd statement. > AFAICS this results in problems when running stuff like > export PS1='test' > manually ­ which IMHO does not work as it should. Hey, you either get a themed prompt or you don't. Why would you expect that assigning to PS1 was enough to disable an entire prompt theme? (Just wait until we get ksh-style "discipline functions," though.) > * Would it be possible that 'prompt -p' does *not* export any > prompt-variables so the prompt doesn't get modified by just > running a preview of one/some/all themes? "prompt -p" doesn't do anything except make a stab at saving state and then blindly run each of the theme setup and preview functions in turn. It's up to the theme writers to make the themes play nice, and some of them don't, er, didn't. Probably preview (and help) could be executed in a subshell nowadays, to avoid all this hassle. When the theme system was first written, some things like the job table didn't behave well in subshells, but that's pretty much been fixed up in 4.2.x. > * Does there exist a way to reset all prompt-values? Something like > 'prompt reset' would be very nice IMHO. Nothing's changed since I wrote the previous response that you excerpted: | To really have "prompt off" mean what it seems to mean, the theme system | would have to save and restore the original values of all the variables. The theme system does not save the original values of all the variables. > * What's the "right" way to set variables in a prompt-theme to avoid > problems with other themes? Would it make sense to "unset PS1 > PS2..." at the beginning of a prompt-theme to avoid any > side-effects from other themes? It's a philosophical thing. E.g. "prompt bart" doesn't mess with RPS1 except to color it; so whatever the previous value was will still be there, which is fine because my prompt doesn't need it for anything. My theme also keeps whatever was in PS1 to begin with, it just prefixes it with more stuff. But none of the prompt themes know about RPS2, because it didn't exist when the theme system was written.