From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21930 invoked from network); 19 Oct 2001 09:49:22 -0000 Received: from unknown (HELO sunsite.dk) (130.225.247.90) by ns1.primenet.com.au with SMTP; 19 Oct 2001 09:49:22 -0000 Received: (qmail 26086 invoked by alias); 19 Oct 2001 09:49:03 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 4404 Received: (qmail 26074 invoked from network); 19 Oct 2001 09:49:02 -0000 Sender: kiddleo@cav.logica.co.uk Message-ID: <3BCFF6C6.D38F9CCC@yahoo.co.uk> Date: Fri, 19 Oct 2001 10:47:50 +0100 From: Oliver Kiddle X-Mailer: Mozilla 4.77 [en] (X11; U; Linux 2.2.15 i686) X-Accept-Language: en MIME-Version: 1.0 To: Jesper Holmberg CC: zsh-users Subject: Re: Number of jobs in prompt References: <20011018234853.C5311@strindberg.maisel.enst-bretagne.fr> <20011019000105.A13783@Amber.lab.icm.edu.pl> <20011019112509.B2300@strindberg.maisel.enst-bretagne.fr> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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