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

Re: multiple background jobs of the same program



"Adam R. Paul" <adamp@xxxxxxx> writes:
> > listjobs() {
> >   jobs >| /tmp/._zshjobcomp.$$ 2>&1
> >   reply=( "${(@f)$(sed -e '{
> >     s/.\(....\).............\(.*\)/%\1 ;: \2/g
> >     s/\]//g
> >     s/  */ /g
> >     }' /tmp/._zshjobcomp.$$)}" )
> > }
> > 
> > compctl -U -Q -K listjobs fg bg kill
> 
> Thanks very much!  Now if I can only get it to work without having 
> menu_complete set, I'll be one happier camper ;-)

I don't like menu_complete either, but it seems that dropping the -U
is enough to make it work in my case (I have about zero knowledge of the
compctl command). One other thing is: I have "jobs" aliased to "jobs -l"
(why would anyone not see the PIDs is beyond me), so I've had to tweak the
regexp. I've seriously tightened it and in the end it looks like this (it
should work whether your "jobs" is aliased to "jobs -l" or not):

complete_listjobs() {
  jobs >| $TMP/zshjobcomp.$$ 2>&1
  reply=( "${(@f)$(sed -e '{
    s/^\[\([0-9][0-9]*\)\] *[-+ ] *\([0-9]* \)[a-z][a-z]*  *\(.*\)/%\1 ;: \2\3/
    }' $TMP/zshjobcomp.$$)}" )
}

compctl -Q -K complete_listjobs fg bg kill


        Stefan



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