Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PS1='%?'
- X-seq: zsh-users 11906
- From: Atom Smasher <atom@xxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: PS1='%?'
- Date: Mon, 1 Oct 2007 00:23:46 +1300 (NZDT)
- In-reply-to: <20070929210907.GA30116@mastermind>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- Openpgp: id=0xB88D52E4D9F57808; algo=1 (RSA); size=4096; url=http://atom.smasher.org/pgp.txt
- References: <20070929112153.76128.qmail@xxxxxxxxxxx> <20070929120210.GB7515@xxxxxxxxxxxxxxx> <20070929151433.45692.qmail@xxxxxxxxxxx> <20070929210907.GA30116@mastermind>
very cool... thanks!
i like that better than messing around with zle.
On Sat, 29 Sep 2007, Matthew Wozniski wrote:
Here's (a very watered down version of) how I do that:
# Set up RPS1 to display $psvar[3], rather than $?
RPS1='%3v'
# When executing a command, set a flag saying that we want $? shown
function preexec {
shownexterr=1
}
# Before drawing the prompt, set $psvar[3] to be "[$?]" or "",
# depending on whether the flag to show it is set and the return was
# non-zero. Then, reset the flag, so the next time precmd runs the
# exit status won't be show.
function precmd {
local exitstatus=$? # Need a local, since other cmds change $?
if [[ "$exitstatus" -gt 0 && "$shownexterr" -gt 0 ]]; then
psvar[3]="[${exitstatus}]"
else
psvar[3]=""
fi
shownexterr=0;
}
--
...atom
________________________
http://atom.smasher.org/
762A 3B98 A3C3 96C9 C6B7 582A B88D 52E4 D9F5 7808
-------------------------------------------------
"I've always thought that underpopulated countries in
Africa are vastly under-polluted."
-- Lawrence Summers,
chief economist of the World Bank,
explaining why we should export toxic wastes
to Third World countries
Messages sorted by:
Reverse Date,
Date,
Thread,
Author