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

Re: multiple background jobs of the same program



It would appear that on Sat, Sep 13, 1997 at 08:26:46PM -0700, Jose Unpingco wrote:
> Hi,
> 
> I often have multiple vi edit sessions going. When I do the completion
> for fg (fg -j  -P % +) that shuffles through the list  of jobs, I only
> get the name of the program, i.e.  vi, which is not very helpful since
> there are multiple vi sessions going. One  way around this is to refer
> to the jobs using the job number.
> 
> Anybody have  any suggestions? I'd really  like to use  the completion
> for fg more productively.

I've often wanted the same thing - I just cooked up a compctl that _almost_
works:

setopt interactive_comments

listjobs() {
jobs > /tmp/._zshjobcomp.$$ 2>&1
set -A reply
OIFS="$IFS"
IFS='
'
reply=( $(sed -e '{
s/.\(....\).............\(.*\)/\1 # \2/g
s/\]//g
s/  */ /g
}' /tmp/._zshjobcomp.$$) )
IFS="$OIFS"
}

compctl -P % -K listjobs fg

The only problem is that zsh is escaping the spaces & #'s that result from 
the completion, which looks really ugly.  Also, I don't really want 
interactive_comments set all the time - just for this completion, but I 
haven't thought of any way to do this (yet:)

Any improvements?  I suspect that the sed bit could be replaced by some neato
zsh internal parameter mangling stuff, but I confess I am not terribly handy
with most of the zsh-specific parameter expansion/substitution features.

_Adam

-----
Adam R. Paul    - adamp@xxxxxxx 
SCO Engineering - #include <stddisclaimer.h>

Sfhacca.  Opnchoiggotl allthouuthqu ut tzhuarlahqu tn'ogo khozhna oomgga.  



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