Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Number of jobs in prompt
- X-seq: zsh-users 4404
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: Jesper Holmberg <jesper.holmberg@xxxxxxxxxxxxxxxx>
- Subject: Re: Number of jobs in prompt
- Date: Fri, 19 Oct 2001 10:47:50 +0100
- Cc: zsh-users <zsh-users@xxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20011018234853.C5311@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> <20011019000105.A13783@xxxxxxxxxxxxxxxxxxxx> <20011019112509.B2300@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Sender: kiddleo@xxxxxxxxxxxxxxxx
Jesper Holmberg wrote:
>
> * On Fri Oct 19, Michal Politowski wrote:
> > have in my prompt the sequence:
> > %(1v.(bg %v%).)
> >
> > and have the following precmd defined:
> > precmd() { psvar[1]=$#jobtexts; [[ $#jobtexts -eq 0 ]] && psvar[1]=(); }
>
> I don't think I understand this solution, and my initial attempts to
> implement it have been unsuccessful. But I'll take a look at it during
> the weekend. Thanks.
An easier solution to understand would be to use setopt promptsubst and include '$#jobtexts' in your PS1 parameter. $#jobtexts expands to the number of elements in the jobtexts array so will give you the number of jobs.
Michal's solution is a bit more clever as it only puts the number of jobs in the prompt if there are more than zero jobs. To do this he uses a ternary expression to test the contents of the psvar array which is set to $#jobtexts from the precmd() function.
Would it be a good idea to add a %j prompt expansion and j test character to prompt expansion to make this easier?
Oliver
Messages sorted by:
Reverse Date,
Date,
Thread,
Author