Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: can i have jobs in my prompt?
- X-seq: zsh-users 1014
- From: Andrew Main <zefram@xxxxxxxxx>
- To: fk5a005@xxxxxxxxxxxxxxxxxx (Matthias Kopfermann)
- Subject: Re: can i have jobs in my prompt?
- Date: Fri, 12 Sep 1997 18:50:30 +0100 (BST)
- Cc: zsh-users@xxxxxxxxxxxxxxx
- In-reply-to: <199709121736.TAA23418@xxxxxxxxxxxxxxxxxxxxxxxxxx> from "Matthias Kopfermann" at Sep 12, 97 07:36:15 pm
Note: I'm CCing this reply to zsh-users, as the answer is likely to be
of general interest.
Matthias Kopfermann wrote:
>i forget how many jobs are running, especially if they are in the background.
>what would you do here?
>
>-f4-7)-%{`builtin jobs`%}-
Don't use %{%}. They are used to indicate a sequence that doesn't move
the cursor, such as a colour escape sequence. Also, $() is recommended
over ``, but in any case jobs doesn't work in a subshell. A possible
approach would be to put something in precmd (a function run before each
prompt) like this:
function precmd {
if jobs % >& /dev/null; then
psvar=("*")
else
psvar=("")
fi
}
And then put "%1v" in your prompt, for example:
PROMPT="%1v> "
and this will put a * in your prompt if there are any background jobs.
You can substitute any other sequence.
I think I might start using this myself.
-zefram
Messages sorted by:
Reverse Date,
Date,
Thread,
Author