zsh-users
 help / color / mirror / code / Atom feed
From: Michal Politowski <mpol@charybda.icm.edu.pl>
To: zsh-users <zsh-users@sunsite.dk>
Subject: Re: Number of jobs in prompt
Date: Fri, 19 Oct 2001 18:38:18 +0200	[thread overview]
Message-ID: <20011019183818.A15827@Amber.lab.icm.edu.pl> (raw)
In-Reply-To: <3BCFF6C6.D38F9CCC@yahoo.co.uk>

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@lab.icm.edu.pl
Warning: this is a memetically modified message


  reply	other threads:[~2001-10-19 16:38 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-10-18 21:48 Jesper Holmberg
2001-10-18 22:01 ` Michal Politowski
2001-10-19  9:25   ` Jesper Holmberg
2001-10-19  9:47     ` Oliver Kiddle
2001-10-19 16:38       ` Michal Politowski [this message]
2001-10-22  0:17       ` Deborah Ariel Pickett
2001-10-18 22:16 ` please unscribe me Matthew Lyon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20011019183818.A15827@Amber.lab.icm.edu.pl \
    --to=mpol@charybda.icm.edu.pl \
    --cc=zsh-users@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).