From: Phil Pennock <Phil.Pennock@globnix.org>
To: zsh-users@sunsite.dk
Subject: Re: get the number of active jobs to show in the prompt?
Date: Mon, 1 Oct 2001 08:37:58 +0200 [thread overview]
Message-ID: <20011001083758.A12916@globnix.org> (raw)
In-Reply-To: <20011001021221.A4623@astaroth.sweth.net>; from svc@sweth.net on Mon, Oct 01, 2001 at 02:12:22AM -0400
[-- Attachment #1: Type: text/plain, Size: 1427 bytes --]
On 2001-10-01 at 02:12 -0400, Sweth Chandramouli wrote:
> 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.
I picked this up from zefram, I think:
jobs % >& /dev/null && psvar[1]="" || psvar[1]=()
Actually, what I have is this:
precmd () {
local exitstatus=$?
psvar[1]=SIG
[[ $exitstatus -ge 128 ]] && psvar[1]=SIG$signals[$exitstatus-127]
[[ $psvar[1] = SIG ]] && psvar[1]=$exitstatus
jobs % >& /dev/null && psvar[2]="" || psvar[2]=()
}
[ switch PS1 depending upon $TERM, but for xterm: ]
PS1=': %2(L.%U[%L]%u.)%(?..%B{%v}%b)%(2v:+:-)%n@%m:%l(%!)%30<..<%~%#; '
The key thing is the %(2v:+:-) -- psvar[2] was set depending upon
whether or not there are background jobs, %(2v:+:-) therefore gives a
'+' if there are background jobs, or a '-' if not.
I _really_ miss having +/- indication of background jobs when forced to
use bash.
--
<-------- The information went data way
[-- Attachment #2: Type: application/pgp-signature, Size: 187 bytes --]
next prev parent reply other threads:[~2001-10-01 6:38 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-10-01 5:56 Drew Perttula
2001-10-01 6:09 ` Goran Koruga
2001-10-01 6:12 ` Sweth Chandramouli
2001-10-01 6:37 ` Phil Pennock [this message]
2001-10-01 6:59 ` Drew Perttula
2001-10-01 7:08 ` Sweth Chandramouli
2001-10-01 8:28 ` Deborah Ariel Pickett
2001-10-01 9:04 ` Phil Pennock
2001-10-01 17:44 ` Vincent Lefevre
2001-10-02 15:43 ` Bart Schaefer
2001-10-02 16:13 ` Vincent Lefevre
2001-10-02 23:25 ` Deborah Ariel Pickett
2001-10-02 23:29 ` unsubscribe me Matthew Lyon
2001-10-03 0:06 ` get the number of active jobs to show in the prompt? Vincent Lefevre
2001-10-03 5:43 ` Bart Schaefer
2001-10-03 14:22 ` Vincent Lefevre
2001-10-03 14:59 ` Vincent Lefevre
2001-10-03 15:11 ` Bart Schaefer
2001-10-03 15:35 ` Vincent Lefevre
2001-10-03 15:58 ` Bart Schaefer
2001-10-03 16:47 ` Vincent Lefevre
2001-10-03 17:09 ` Bart Schaefer
2001-10-03 19:34 ` Vincent Lefevre
2001-10-03 20:01 ` Bart Schaefer
2001-10-03 20:08 ` Vincent Lefevre
2001-10-03 21:46 ` Bart Schaefer
2001-10-03 21:51 ` Bart Schaefer
2001-10-03 23:15 ` Vincent Lefevre
2001-10-04 0:05 ` Bart Schaefer
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=20011001083758.A12916@globnix.org \
--to=phil.pennock@globnix.org \
--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).