Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: get the number of active jobs to show in the prompt?

On Sun, Sep 30, 2001 at 10:56:50PM -0700, Drew Perttula wrote:
> Hello everyone-
> 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.
	zsh spawns a subshell for the LHS of a pipe, rather than
the RHS, which lets you do things like 

$ do_something | read VAR

	and have VAR still be set.  That means that jobs in your
example is being run in a subshell where there _aren't_ any background
jobs.  The only way I can think of offhand to get the info from jobs
would be to redirect the output of jobs to a temp file and then use that
to build your prompt; that's not very efficient, however.  I don't know
if there's some other way to get that info from the shell.

	-- Sweth.

Sweth Chandramouli ; <svc@xxxxxxxxx>
President, Idiopathic Systems Consulting

Attachment: pgpeopM4DlZxP.pgp
Description: PGP signature

Messages sorted by: Reverse Date, Date, Thread, Author