From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22603 invoked from network); 1 Oct 2001 08:28:36 -0000 Received: from sunsite.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 1 Oct 2001 08:28:36 -0000 Received: (qmail 24070 invoked by alias); 1 Oct 2001 08:28:13 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 4305 Received: (qmail 24056 invoked from network); 1 Oct 2001 08:28:12 -0000 From: Deborah Ariel Pickett Message-Id: <200110010828.SAA20292@bruce.csse.monash.edu.au> Subject: Re: get the number of active jobs to show in the prompt? To: drewp@bigasterisk.com (Drew Perttula) Date: Mon, 1 Oct 2001 18:28:04 +1000 (EST) Cc: zsh-users@sunsite.dk In-Reply-To: <200110010600.f9160iq10821@bang.houseoflove> from "Drew Perttula" at Sep 30, 2001 10:56:50 PM X-Mailer: ELM [version 2.5 PL3] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Drew wrote: > I'm tired of using my close-window shortcut to zap shells > that still owned running programs, so I'd like my zsh prompt > to indicate that somehow. I can't figure out how to do anything > programmatically with the 'jobs' command (such as "jobs | wc -l"), > so I'm lost as to how to do my prompt trick. Looks like you've already got an answer, but there are better ways to do this from zsh 3.1.9 onwards. The "zsh/parameter" module defines three variables, among others: jobdirs, jobtexts, and jobstates. They're normal associative arrays, which means you can do things like this: numberofjobs=$#jobstates without having to invoke subshells or other yucky things you really want to keep out of the shell prompt generation code. If you want to count just running jobs, or suspended jobs, this appears to work (but it probably isn't the natural way to do it; I just made up this solution by simulated annealing): numberofsuspendedjobs=${(Mw)#jobstates#suspended:} s/suspended/running/g for running jobs. Insert "zmodload zsh/parameter" in a suitable zsh startup file (such as .zshrc) before trying this. -- Debbie Pickett http://www.csse.monash.edu.au/~debbiep debbiep@csse.monash.edu.au "As far as my eyes can see there are shadows surrounding me. And to those I leave behind, I want you all to know you've always shared my darkest hours, I'll miss you when I go." - _Old and Wise_, The Alan Parsons Project