zsh-users
 help / color / mirror / code / Atom feed
* named jobs in RPROMPT
@ 2011-09-18 14:48 Daniel
  0 siblings, 0 replies; 5+ messages in thread
From: Daniel @ 2011-09-18 14:48 UTC (permalink / raw)
  To: zsh-users

I wanted to have a list of background jobs, with names (and some little
marker for suspended/running) in RPROMPT. I tried by turning on prompsubst
and made jobfunction which print $jobstates and then set
RPROMPT=$(jobfunction) But I get nothing, it seems jobstates is empty
during prompt generation? How can I do this?



^ permalink raw reply	[flat|nested] 5+ messages in thread
* RE: named jobs in RPROMPT
@ 2011-09-19 23:42 fhml
  2011-09-20  7:27 ` Daniel
  0 siblings, 1 reply; 5+ messages in thread
From: fhml @ 2011-09-19 23:42 UTC (permalink / raw)
  To: zsh-users

Hey there.

> [...] and then set
>RPROMPT=$(jobfunction) But I get nothing, it seems jobstates is empty
>during prompt generation?

When you do >>PROMPT=$(code)<< then 'code' gets executed and the result is stored in PROMPT. Sometimes that is not what you want. What you probably want is >>PROMPT='$(code)'<<. See the little 's? Those prevent 'code' from being evaluated immediately. Now the code gets evaluated every time the PROMPT is shown.

A simple example where 'code' is 'date'. Lets say its currently 1970-01-01 00:00:00. When you enter >>PROMPT=$(date)<<, '$(date)' gets evaluated immediately, which is the same as if you typed >>PROMPT="1970-01-01 00:00:00"<<. Of course, that will never change. If you use 's, then '$(date)' gets stored in PROMPT - just as you typed it, not evaluated. Now every time PROMPT is evaluated '$(date)' gets evaluated which gives you a brand new date every time your PROMPT is updated.

Greetings :)


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-09-25 17:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-18 14:48 named jobs in RPROMPT Daniel
2011-09-19 23:42 fhml
2011-09-20  7:27 ` Daniel
2011-09-20 19:04   ` Julien Jehannet
2011-09-25 17:39   ` Bart Schaefer

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).