Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Number of jobs in prompt
- X-seq: zsh-users 4405
- From: Michal Politowski <mpol@xxxxxxxxxxxxxxxxxxx>
- To: zsh-users <zsh-users@xxxxxxxxxx>
- Subject: Re: Number of jobs in prompt
- Date: Fri, 19 Oct 2001 18:38:18 +0200
- In-reply-to: <3BCFF6C6.D38F9CCC@xxxxxxxxxxx>
- Mail-followup-to: 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> <3BCFF6C6.D38F9CCC@xxxxxxxxxxx>
On Fri, 19 Oct 2001 10:47:50 +0100, Oliver Kiddle wrote:
> 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.
Yes. I guess I should have written it explicitely instead of presenting my
solution.
> 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.
Actually with promptsubst I could use
${${${#jobtexts}:#0}/?*/(bg $#jobtexts)}
which looks even more unparsable than the original, but leaves psvar and
precmd free.
I even think I'll make the change.
> Would it be a good idea to add a %j prompt expansion and j test character to prompt expansion to make this easier?
I can say, I'd use it instead of my inventions.
--
Michal Politowski -- mpol@xxxxxxxxxxxxxx
Warning: this is a memetically modified message
Messages sorted by:
Reverse Date,
Date,
Thread,
Author