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

Some questions regarding prompt themes



Hello,

I've tested the below documented behaviour with zsh versions 4.2.0
and 4.2.1 (CVS-sources). Some time ago I wrote my own prompt-themes
and noticed a (at least for me) strange and maybe unwanted
behaviour:

$ zsh -f
$ echo $PROMPT $PS1 $PS2 $PS3 $PS4
%m%#  %m%#  %_>  ?#  +%N:%i>
$ autoload promptinit && promptinit
$ prompt -p           # Preview given themes (defaults to all)
[...]
mika@tweety ~ %

Now I've a PROMPT-variable different from the above ("%m%# ").

Bart Schaefer wrote:

,---- [ Quoting http://www.zsh.org/mla/workers/2003/msg00434.html ]
| } One problem I noticed the other day is if one prompt sets PS3, PS4, or
| } RPS1, then those vars won't get reset when changing prompts, even when
| } setting the prompt to "off".
|
| It's a general shortcoming that themes only change the parts of the prompt
| that they're interested in; "off" is just another theme with a silly name.
|
| 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.
`----

My questions:

* In the prompt-theme "walters" exists a "export PROMPT=...":

$ grep -l export /usr/share/zsh/4.2.0/functions/Prompts/prompt*
  /usr/share/zsh/4.2.0/functions/Prompts/prompt_walters_setup

  Is using 'export PROMPT' in prompt-themes reasonable?

* Is it possible to "break out" of a precmd­statement?
  Some themes are using the precmd-option:

$ pwd && grep -l precmd *prompt*  | wc -l
  /usr/share/zsh/4.2.0/functions/Prompts
  13
$ grep 'precmd.*prompt_' *prompt* | wc -l
  8

  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.

* 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?

* Does there exist a way to reset all prompt-values? Something like
  'prompt reset' would be very nice IMHO.

* 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?

thanks for any feedback && regards,
(-: Michael
-- 
A german webpage for zsh / eine deutsche Webpage zur zsh:
http://www.michael-prokop.at/computer/tools_zsh.html
Die Zsh-Liebhaber-Seite:
http://www.michael-prokop.at/computer/tools_zsh_liebhaber.html



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