zsh-users
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@candle.brasslantern.com>
To: Robert Stone <rstone@accesscom.com>, zsh-users@math.gatech.edu
Subject: Re: zsh propmts
Date: Sun, 18 Aug 1996 11:43:12 -0700	[thread overview]
Message-ID: <960818114312.ZM23497@candle.brasslantern.com> (raw)
In-Reply-To: Robert Stone <rstone@accesscom.com> "zsh propmts" (Aug 18,  3:42am)

On Aug 18,  3:42am, Robert Stone wrote:
} Subject: zsh propmts
}
} 	I've been attempting to set up a prompt that will show me any 
} non-zero return values, and print the names of any signal the last job 
} recieved.  Right now I'm using two features of the shell to accomplish this:
} 
} function precmd { PSVAR=$signals[$?^128+1] }
} PROMPT='%(?..%1(?.{%?}.%B{%?%2(v.. %v)}%b) )%m:%~%# '
} 
} 	Unfortunately I end up with $PSVAR = '.' if no signal has occured 

This looks like a bug in the PSVAR handling.  Note that PSVAR is a colon-
separated list corresponding to the psvar array.  Assignments to PSVAR
are thus being treated in a manner similar to assignments to PATH, which
means that PSVAR can never be made empty by direct assignment -- an empty
assignment assigns dot instead.

If you use psvar instead of PSVAR, things work better:

function precmd { psvar=($signals[$?^128+1]) }
PROMPT='%(?..%1(?.{%?}.%B{%?%2(v.. %v)}%b) )%m:%~%# '

Unfortunately, there also seems to be a bug with %2(v.. %v) because it
evaluates to a space when $#psvar == 0.  So it looks better this way:

PROMPT='%(?..%1(?.{%?}.%B{%?%1(v. %v.)}%b) )%m:%~%# '

} 	The trick here is that I can't execute anything in precmd that would 
} effect $? or the "%?" value in the prompt is inaccurate.

Really?  That shouldn't be the case.  $? is supposed to get reset to its
original value after precmd exits.  All you have to do is be sure that
the assignment to psvar is the very first thing that happens in precmd.

-- 
Bart Schaefer                             Brass Lantern Enterprises
http://www.well.com/user/barts            http://www.nbn.com/people/lantern

New male in /home/schaefer:
>N  2 Justin William Schaefer  Sat May 11 03:43  53/4040  "Happy Birthday"


      reply	other threads:[~1996-08-18 18:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-08-18  8:42 Robert Stone
1996-08-18 18:43 ` 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=960818114312.ZM23497@candle.brasslantern.com \
    --to=schaefer@candle.brasslantern.com \
    --cc=rstone@accesscom.com \
    --cc=schaefer@nbn.com \
    --cc=zsh-users@math.gatech.edu \
    /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).