zsh-users
 help / color / mirror / code / Atom feed
From: Roman Perepelitsa <roman.perepelitsa@gmail.com>
To: Christopher Nebel <c.nebel@apple.com>
Cc: zsh-users <zsh-users@zsh.org>
Subject: Re: Processing "%?" in PROMPT?
Date: Wed, 20 Nov 2019 22:42:00 +0100	[thread overview]
Message-ID: <CAN=4vMrm1BMEmqTNEB00CBwpXL-Rv9r6TGPjWasaBTiU+zOyqA@mail.gmail.com> (raw)
In-Reply-To: <2879A761-D4D3-44C5-8D54-D58D9E3F5EBF@apple.com>

On Wed, Nov 20, 2019 at 10:28 PM Christopher Nebel <c.nebel@apple.com> 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.

      reply	other threads:[~2019-11-20 21:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-20 21:27 Christopher Nebel
2019-11-20 21:42 ` Roman Perepelitsa [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAN=4vMrm1BMEmqTNEB00CBwpXL-Rv9r6TGPjWasaBTiU+zOyqA@mail.gmail.com' \
    --to=roman.perepelitsa@gmail.com \
    --cc=c.nebel@apple.com \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).