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

Re: get output of a command in prompt



On 2006-09-16 at 20:49 +0200, arno. wrote:
> So I have something like :
>  RPS1="%2v"
>  and 
> 
> precmd() {
>     gettemp
> }

> > Some people make the mistake of using it [precmd function] to set up a 
> > prompt, but there are enough ways of getting varying information into a 
> > fixed prompt string that you shouldn't do that unless you have very odd 
> > things in your prompt.
> http://zsh.sunsite.dk/Guide/zshguide03.html#l51
> 
> But I didn't find a better way to do what I want. Did I miss something, 
> or is my goal something "very odd".

I interpret the user guide text to mean "Don't set the prompt in
precmd()", given the following text: "It's a big nuisance having to
redefine precmd to alter your prompt --- especially if you don't know
it's there, since then your prompt apparently magically returns to the
same format when you change it."


So they're saying that instead of using:
 function precmd { RPS1="$(gettemp)" }
you should instead do exactly what you are doing.

For a distributed example of using precmd, see the various
prompt_*_setup routines; in particular, prompt_zefram_setup shows
something manipulating various $psvar values for later display in the
prompt.

Regards,
-Phil



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