Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: zsh propmts



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"



Messages sorted by: Reverse Date, Date, Thread, Author