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 Wed, Oct 03, 2001 at 05:43:50 +0000, Bart Schaefer wrote:
> 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

I get errors like

push-line-at-random:bindkey:5: no such keymap `\163'

But I don't understand what you mean.

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

I still don't understand the problem.

> 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" }

This doesn't solve my problem: for instance, after a Ctrl-L, the
message disappears. I think that the best thing I can do is to put
the jobs status directly to the terminal title, and this can be
done with TRAPCLD.

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

This is not what I want. I just want the prompt to reflect the jobs
status. Currently, my prompt is yellow when there are no jobs, and
green when there is at least one job.

-- 
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <http://www.vinc17.org/> - 100%
validated HTML - Acorn Risc PC, Yellow Pig 17, Championnat International des
Jeux Mathématiques et Logiques, TETRHEX, etc.
Work: CR INRIA - computer arithmetic / SPACES project at LORIA



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