From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9324 invoked from network); 14 Sep 1997 22:12:03 -0000 Received: from math.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 14 Sep 1997 22:12:03 -0000 Received: (from list@localhost) by math.gatech.edu (8.8.5/8.8.5) id SAA11580; Sun, 14 Sep 1997 18:06:38 -0400 (EDT) Resent-Date: Sun, 14 Sep 1997 18:06:22 -0400 (EDT) Message-ID: <19970914150505.11879@sco.com> Date: Sun, 14 Sep 1997 15:05:05 -0700 From: "Adam R. Paul" To: Bart Schaefer Cc: zsh Subject: Re: multiple background jobs of the same program References: <9709140326.AA21133@cryptica.UCSD.EDU> <19970914102839.45957@sco.com> <970914121042.ZM22784@candle.brasslantern.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.81 In-Reply-To: <970914121042.ZM22784@candle.brasslantern.com>; from Bart Schaefer on Sun, Sep 14, 1997 at 12:10:42PM -0700 Resent-Message-ID: <"qR6cZ3.0.Qq2.T_57q"@math> Resent-From: zsh-users@math.gatech.edu X-Mailing-List: archive/latest/1019 X-Loop: zsh-users@math.gatech.edu X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu It would appear that on Sun, Sep 14, 1997 at 12:10:42PM -0700, Bart Schaefer wrote: > On Sep 14, 10:28am, Adam R. Paul wrote: > } Subject: Re: multiple background jobs of the same program > } > } 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 > > Change it to > > compctl -Q -P % -K listjobs fg > > } Also, I don't really want > } interactive_comments set all the time > > 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 :( 'fg ' yields 'fg %' and no number of tabs causes it to complete anything, which is unfortunate, as I don't like menu_complete personally - I prefer to have completion complete as far as is unambiguous, auto-list the completions and then do menu completion if is pressed after that. I think the options that I use to do this are autolist and list_ambiguous ( but not menu_complete). > } Any improvements? > > 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 through anything results in the RHS of the pipe getting nothing whatsoever (ie. 'jobs | cat' produces nothing at all, 'jobs | echo' produces just a newline). It'd be nice if there was another way to do this - I also have the somewhat silly: precmd() { jobs > /tmp/.zsh_jobs.$$ psvar=$(wc -l < /tmp/.zsh_jobs.$$ | tr -d ' ') } PS1='%%%1v:%~%#' to get the number of jobs in my prompt. > You don't need `set -A reply'. True, dunno why I had that in there :) > Don't change IFS, use "${(@f)...}" to interpret each line as a word. Ah, most excellent! I'll have to tweak a few other compctls I have to use that (and read up on that construct in the man page:) > Have listjobs insert the leading % instead of using -P, and use -U to > cause the line so far to be replaced by the completion. Then when there > are no possible completions (no jobs), nothing gets inserted. (Your > original inserts "% " when there are no jobs.) > > Do the completion for `bg' and `kill', too. Naturally. That was my intention once I got it working the way I wanted it. > } I suspect that the sed bit could be replaced by some neato > } zsh internal parameter mangling stuff > > Since you're doing several substitutions and already reading from a file, > I don't think that's worth it. > > Finished product: > > 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 ;-) Thanks, _Adam ----- Adam R. Paul - adamp@sco.com SCO Engineering - from std import disclaimer Pdro. Aunagl gyeaoi tuthshaothyi iafhthath iagcha.