Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: get output of a command in prompt
- X-seq: zsh-users 10728
- From: Dan Nelson <dnelson@xxxxxxxxxxxxxxx>
- To: "arno." <arno.@xxxxxxxxxx>
- Subject: Re: get output of a command in prompt
- Date: Sun, 17 Sep 2006 12:09:14 -0500
- Cc: zsh-users@xxxxxxxxxx
- In-reply-to: <20060917141420.GA5288@xxxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20060916184913.GA18417@xxxxxxxxxxxxxxxxxxxxx> <20060916190154.GA24023@xxxxxxxxxxxxxxx> <20060917141420.GA5288@xxxxxxxxxxxxxxxxxxxxx>
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