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

Re: Processing "%?" in PROMPT?



On Wed, Nov 20, 2019 at 10:28 PM Christopher Nebel <c.nebel@xxxxxxxxx> wrote:
> My first attempt was to set PROMPT to ‘$(pretty-status %?)’

$? will work the way you want if it's the first command substitution
in PROMPT. The same goes for RPROMPT.

> I could use a precmd function to save $? in a global, but only if
> I could guarantee that it was called before anything else, and that’s
> not a promise I’m comfortable making.

$? (a.k.a. $status) and $pipestatus are guaranteed to work as you
expect when precmd hooks are called. It's quite common to stash them
into global variables there.


Roman.



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