Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: multiple background jobs of the same program
- X-seq: zsh-users 1020
- From: "Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxx>
- To: "Adam R. Paul" <adamp@xxxxxxx>
- Subject: Re: multiple background jobs of the same program
- Date: Sun, 14 Sep 1997 16:09:10 -0700
- Cc: zsh <zsh-users@xxxxxxxxxxxxxxx>
- In-reply-to: <19970914150505.11879@xxxxxxx>
- References: <9709140326.AA21133@xxxxxxxxxxxxxxxxx> 	<19970914102839.45957@xxxxxxx> 	<970914121042.ZM22784@xxxxxxxxxxxxxxxxxxxxxxx> 	<19970914150505.11879@xxxxxxx>
On Sep 14,  3:05pm, Adam R. Paul wrote:
} Subject: Re: multiple background jobs of the same program
}
} > Replace the `#' with `;:'.  This works best if you have menu completion
} > so that the `;' isn't interpreted as a command separator until after you
} > have a chance to cycle through all the possibilities.
} 
} Hmm, it doesn't appear to work at all unless menu_complete is set :(  
I use automenu, not menucomplete, and it's OK there ....
However, it works for me with autolist and listambiguous, at least as far
as getting the listing:
zagzig[37] fg <TAB>
%1 ;: vim fo       %2 ;: info -f zsh  %3 ;: vim bar
zagzig[37] fg %
At this point if I hit TAB again I get a beep, and if I supply (say) the
digit 1 and then hit TAB I encounter what must be a completion bug:
zagzig[37] fg %1<TAB>
zagzig[37] fg %^@1
%1 ;: vim fo       %2 ;: info -f zsh  %3 ;: vim bar
zagzig[37] fg %
That ^@ in there is a nul byte that zsh is incorrectly inserting.  It then
gets erased by compctl -U, but it shouldn't be there to begin with.
Anyway, the ;: has nothing to do with this particular problem -- get rid of
the -U if you don't use automenu or menucomplete, and things should be much
better.
I just played around with this a bit and discovered that you don't need -U
at all as long as reply is an empty array (rather than an array containing
the empty string) when there are no jobs -- which you can do by testing
whether "jobs" produced any output before running the "sed".  See below.
} > Either remove the temp file or use >| so `setopt clobber' isn't needed.
} 
} I'd love to not use a temp file, but it appears that piping 'jobs' output
No, I didn't mean don't use the temp file; I meant end the function with
"rm /tmp/._zshjobcomp.$$".
Anyway, to summarize:
listjobs() {
  jobs >| /tmp/._zshjobcomp.$$ 2>&1
  if [[ -s /tmp/._zshjobcomp.$$ ]]
  then
   reply=( "${(@f)$(sed -e '{
    s/.\(....\).............\(.*\)/%\1 ;: \2/g
    s/\]//g
    s/  */ /g
    }' /tmp/._zshjobcomp.$$)}" )
  else
   reply=()
  fi
}
compctl -Q -K listjobs fg bg kill
-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com
Messages sorted by:
Reverse Date,
Date,
Thread,
Author