zsh-users
 help / color / mirror / code / Atom feed
* zsh propmts
@ 1996-08-18  8:42 Robert Stone
  1996-08-18 18:43 ` Bart Schaefer
  0 siblings, 1 reply; 2+ messages in thread
From: Robert Stone @ 1996-08-18  8:42 UTC (permalink / raw)
  To: zsh-users


	I'd like to thank everyone who had anything to do with the "%_" 
value for PS2 in zsh-3.0.0, I'm in love with it.

	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 
because an invalid array subscription produces '.', such that my prompt 
looks like:

aic1:~% return 15
{15 .} aic1:~% ls -l            # I hit ^C here
{130 INT} darkstar:~%

	The trick here is that I can't execute anything in precmd that would 
effect $? or the "%?" value in the prompt is inaccurate.  How could I clean 
this so that PSVAR is set to a null string when $signals is given an invalid 
subscript?
							thanks,
							Robert Stone

------------------rstone@accesscom.com-------------------
#!/bin/perl -sp0777i<X+d*lMLa^*lN%0]dsXx++lMlN/dsM0<j]dsj
$/=unpack('H*',$_);$_=`echo 16dio\U$k"SK$/SM$n\EsN0p[lN*1
lK[d2%Sa2/d0$^Ixp"|dc`;s/\W//g;$_=pack('H*',/((..)*)$/)



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: zsh propmts
  1996-08-18  8:42 zsh propmts Robert Stone
@ 1996-08-18 18:43 ` Bart Schaefer
  0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 1996-08-18 18:43 UTC (permalink / raw)
  To: Robert Stone, zsh-users

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"


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1996-08-18 18:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-08-18  8:42 zsh propmts Robert Stone
1996-08-18 18:43 ` Bart Schaefer

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).