From: Bart Schaefer <schaefer@brasslantern.com>
To: Elliott Cable <me@ell.io>
Cc: zsh-users@zsh.org
Subject: Re: How can I maintain my last command’s exit-status while resetting my prompt in ZSH?
Date: Fri, 11 Feb 2011 08:26:13 -0800 [thread overview]
Message-ID: <AANLkTinerHxXBs4vc_+UXFMxsrui7EKBNhdH01a0wqn6@mail.gmail.com> (raw)
In-Reply-To: <AANLkTikFsJGitoiU49kJphErOsxbCN_BrerNcaHcb2kR@mail.gmail.com>
On Thu, Feb 10, 2011 at 10:03 PM, Elliott Cable <me@ell.io> wrote:
>
> The problem: When the keymap changes (that is, when I toggle through
> the “command” and “insert” modes using, as an example, `a` and then
> the escape key, the `$?` exit-status is overtrodden with a successful
> `0` status, thus causing the prompt to display in green instead of red
> (even if the previous command failed). How can I save or set the
> prompt such that the `%(?|…|…)` portions of `$PS1` will properly
> display the exit status of the *last command sent to the shell*?
This was fixed in July 2010, so eventually you won't need to do anything:
* users/15217: Src/Zle/zle_main.c: use top-level status
when redrawing prompt.
In the meantime, try this:
function zle-keymap-select {
local Q=$?
psvar[1]="${${KEYMAP/(main|viins)/>}/vicmd/}"
(return $Q)
zle reset-prompt
psvar[1]=""
}
If your zsh is recent enough to have anonymous functions, you can replace
the subshell (return $Q) with (){ return $Q }.
prev parent reply other threads:[~2011-02-11 16:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-11 6:03 Elliott Cable
2011-02-11 16:26 ` Bart Schaefer [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=AANLkTinerHxXBs4vc_+UXFMxsrui7EKBNhdH01a0wqn6@mail.gmail.com \
--to=schaefer@brasslantern.com \
--cc=me@ell.io \
--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).