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

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



On Oct 3,  2:06am, Vincent Lefevre wrote:
}
} The current command should be saved in a safe place. Then, the necessary
} functions (e.g., precmd()) should be called. Finally, the current command
} should be restored and displayed with the new prompt(s).

This is the sort of thing that sounds good in theory, but will drive you
insane in practice.  For some sort of inkling of how it would feel, try
using this:

 function push-line-at-random {
   local nested=${(%):-%_}
   zle self-insert
   print '\n[0]  + done       pretend a job finished'
   bindkey $KEYS self-insert
   bindkey -M $KEYMAP \\$(([##8](RANDOM % 26 + ##a))) push-line-at-random
   if [[ -n $nested ]]
   then
     zle push-line-or-edit
     zle beep
   else
     zle push-input
     zle send-break
   fi
 }
 zle -N push-line-at-random
 bindkey \\$(([##8](RANDOM % 26 + ##a))) push-line-at-random

Aside from the stuff that Deborah mentioned, most of which is correct,
there's the question of what to do when you're at the "bck-i-search:"
prompt (or other "minibuffer" prompts), or when you're in menu-select,
or when you're in the middle of some long-running user-defined widget
such as incremental-complete-word.

While someone (not me, this time) is deciding whether they want to
attempt to come up with a clean way to deal with all of this, you might
look at what you can do with "zle -I" and "zle -M".  For example:

    TRAPCLD() { zle -I && zle -M "jobs: $#jobstates running" }

It's too bad that this does two redraws (one for the notify output and
again because of `zle -I') but at least it shows the info you want.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   



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