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

Re: get the number of active jobs to show in the prompt?



> Actually, what I have is this:
> precmd () {
> 	local exitstatus=$?
> 	psvar[1]=SIG 
> 	[[ $exitstatus -ge 128 ]] && psvar[1]=SIG$signals[$exitstatus-127] 
> 	[[ $psvar[1] = SIG ]] && psvar[1]=$exitstatus 
> 	jobs % >& /dev/null && psvar[2]=""  || psvar[2]=() 
> }
> [ switch PS1 depending upon $TERM, but for xterm: ]
> PS1=': %2(L.%U[%L]%u.)%(?..%B{%v}%b)%(2v:+:-)%n@%m:%l(%!)%30<..<%~%#; '
> 
> The key thing is the %(2v:+:-)  --  psvar[2] was set depending upon
> whether or not there are background jobs, %(2v:+:-) therefore gives a
> '+' if there are background jobs, or a '-' if not.

It seems like the + and - come at the reverse times than you say, 
but, just the same, this looks like what I want.

Thanks everyone for the quick responses!

-Drew





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