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

Re: get output of a command in prompt



In the last episode (Sep 17), arno. said:
> Le Saturday 16 September 2006, à 21:01:55PM +0200, Frank a écrit : 
> > arno. <arno.@xxxxxxxxxx>:
> > [..get output of command into prompt..]
> > 
> > Take a look at this:
> > 
> > [snip]
> > zsh% PS1='$(printf "%s: %d" "This is a one" 1)-%% '
> > $(printf ": /home/hawk" "This is a one" 1)-% setopt promptsubst 
> > This is a one: 1-%
> > [snap]
> 
> Yes, I've tried things like that, but the problem is that command output 
> will be evaluated once, just when prompt is set up. It will not be 
> evaluated each time prompt is displayed

That example does evalute the prompt each time it's printed; you just
can't tell.  Try with a command that changes its output:

zsh% PS1='$(date)-%% ' ; setopt promptsubst
Sun Sep 17 12:06:02 CDT 2006-% <press enter>
Sun Sep 17 12:06:33 CDT 2006-% <press enter>
Sun Sep 17 12:06:34 CDT 2006-% 

Of course in this example you'd be better off using zsh's builtin
date-printing prompt escapes, but you get the idea.

-- 
	Dan Nelson
	dnelson@xxxxxxxxxxxxxxx



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