Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Execute a Command in PS1 w/o Disturbing Previous Return Value?
- X-seq: zsh-users 7838
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: Execute a Command in PS1 w/o Disturbing Previous Return Value?
- Date: Fri, 13 Aug 2004 10:32:32 -0700 (PDT)
- In-reply-to: <D0F204E0-ECD9-11D8-83BE-000502631FBD@xxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <D0F204E0-ECD9-11D8-83BE-000502631FBD@xxxxxxxxxxxxxx>
- Reply-to: zsh-users@xxxxxxxxxx
On Thu, 12 Aug 2004, Aaron Davies wrote:
> I'm trying to write a prompt that will do two things: include a file
> frequently re-downloaded from the web, and indicate the return status of
> the previous command. The problem is, if I cat out the file, it returns
> 0, overwriting the return status read by the %(0?%) directive
This should probably be considered a bug.
> What can I do about this?
In addition to Philippe's suggestion of using precmd so that $? is saved
and restored for you by the shell -- which is what should be happening
during command substitutions in prompt expansion, but isn't -- a simple
alternative is to use $(<...) instead of `cat ...`.
You can also use $'...' instead of `echo '...'`
export PS1='$(</tmp/temperature)'" %m%~ %(0?."\
$'%{\e[1;32m%}:)%{\e[0m%}.%{\e[1;31m%}:(%{\e[0m%}'") %# "
Messages sorted by:
Reverse Date,
Date,
Thread,
Author