Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: named jobs in RPROMPT
<fhml <at> herrmann-koenigsberg.de> writes:
>
> 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.
I'm well aware of the function of single-quotes and the need for them here.
Sorry I omitted them from what was pseudo-code but didn't look like that ;)
But thanks anyway, because now I tried to minimize my code even more.
setopt promptsubst
Now consider:
RPROMPT='"$jobstates"'
and
my_jobs() { print $jobstates }
RPROMPT='"$(my_jobs)"'
The first one display the jobstates array, the second doesn't. Also, running
my_jobs from the prompt does display the array. Could this be because inside
the function, there are no background jobs? It's in a different context, or
something like that?
My idea is to have my_jobs print a very compact list of jobs, fitting in
the right prompt.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author