Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PS1='%?'
- X-seq: zsh-users 11903
- From: Matthew Wozniski <godlygeek@xxxxxxxxx>
- To: Atom Smasher <atom@xxxxxxxxxxx>
- Subject: Re: PS1='%?'
- Date: Sat, 29 Sep 2007 17:09:09 -0400
- Cc: zsh-users@xxxxxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:received:date:from:to:cc:subject:message-id:references:mime-version:content-type:content-disposition:in-reply-to:user-agent; bh=pYw7L2U2/nW/1RVbHCpjczkx+ggk+4by96akGfFz5B4=; b=ekVBPhXssvSoYoVmgOuncwel/7ykClB7skVkY7dYwPlRrkjJ6OCmiqIvGGNi+FJL9DDlUlgpK9KYKgKOZMQQqeuS5kpMiuc7oa5BlVNNh5bwCzmhgH4vWfBE50XnCaDgk6d7q2oVBRoAkKm4/NqmxBL/AhPJGRUfzhXEq2Jkf78=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:date:from:to:cc:subject:message-id:references:mime-version:content-type:content-disposition:in-reply-to:user-agent; b=gGOhbjqyi//ffzt8ezfSsEOeFChfHOW1V37Gjf1oVtP+LO7+BXoBVlGO2RLQ0D3rtw7xxLXWwl05y0xRb3T9sKCoQLVzCsEp0laXx7/PeyZefwc1AI4/BjhXvZhQ8+5ftsYBlBasuANc7ELZrsyy8y07KoTnLYTGOHmAIIFH17Y=
- In-reply-to: <20070929151433.45692.qmail@xxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20070929112153.76128.qmail@xxxxxxxxxxx> <20070929120210.GB7515@xxxxxxxxxxxxxxx> <20070929151433.45692.qmail@xxxxxxxxxxx>
On Sun, Sep 30, 2007 at 03:14:27AM +1200, Atom Smasher wrote:
> if a command returns non-zero, i see the return status in my prompt.
> sometimes that can be a distraction, and i'd like to "clear" it by hitting
> <return>.
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;
}
Messages sorted by:
Reverse Date,
Date,
Thread,
Author