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

Re: get the number of active jobs to show in the prompt?

Vincent wrote:
> On Tue, Oct 02, 2001 at 15:43:13 +0000, Bart Schaefer wrote:
> > There's no option to get that behavior because, in general, regenerating
> > the prompt might change too much of the editor state.  For example, what
> > if you're editing at the secondary prompt (e.g., on the second or later
> > line of a shell function or quoted string)?
> I don't see the problem. Could you give an example?

I thought the above paragraph *was* the example . . .

OK, this example's not quite the same as Bart's, but it's close.
Say you're in the middle of typing the following code:

primary-prompt-with-job-info-in-it> for x in foo bar baz
secondary-prompt> do
secondary-prompt>   echo 
and the cursor is right there when a job finishes.

What you seem to want is for zsh to instantly be interrupted and have it
re-process the prompt.

How?  Should it run precmd() again to do so?  What if there's stuff in
precmd() that isn't to do with generating the prompt, but is instead
involved in dealing with command history?  You wouldn't want that to run
again, because you haven't finished typing your command.

I also believe that when you're typing a multi-line command like the one
above, the individual lines that make it up aren't joined together into
the command history as one command until the whole command is complete.
(zsh developers, please correct me if I'm wrong.) Re-displaying the
multi-line command thus isn't going to be easy.  It certainly can't be
done with user-level zsh programming.

Yes, of course zsh could be modified to do what you want.  Personally,
I'd love it, because I was trying to do a similar thing a few months
back, but I don't think it's very high on the zsh developers' list of
priorities.  (I'm not one of them, so correct me if I'm wrong.)

(What I was trying a few months back was something that would set an
alarm trap to go off in a few minutes, and catch it with a trap handler
that would re-generate the prompt.  It would then repeat the process,
ensuring that the prompt was always up-to-date.  Thus if I was away from
my terminal I could see immediately how many messages were waiting for
me by looking at the relevant part of the prompt.  It didn't work, for
the reasons Bart relates, so I just got in the habit of pressing ENTER
to re-print the prompt when I came back to my machine.  One extra
keypress hasn't killed me.)

Debbie Pickett http://www.csse.monash.edu.au/~debbiep debbiep@xxxxxxxxxxxxxxxxxx
    "Am I - d-dead?" "No." "We could fix that for you . . ." - _FernGully_

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