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

RE: named jobs in RPROMPT



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



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