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

Re: multiple background jobs of the same program



On Sep 15,  7:26am, Stefan Monnier wrote:
> Subject: Re: multiple background jobs of the same program
>
> I must be stupid, because a much simpler alternative works just as well if not
> better:

What's $TMP ?  When I first cut'n'pasted this, I got

zsh: permission denied: /zshjobcomp.30447

Here's a better idea:

    complete_listjobs() {
      tmpfile=${TMPPREFIX}jobcomp.$$
      jobs >&| $tmpfile
      if [[ -s $tmpfile ]] then
         reply=("${(@f)$(sed -e 's/^\[\([0-9]*\)\][-+ ]*/%\1 ;: /' $tmpfile)}")
      else
        reply=()
      fi
    }
     
    compctl -Q -K complete_listjobs fg bg kill

If not for the nofunctionargzero option, I'd use $TMPPREFIX$0.$$ for the
temp file name.

> - only list the plainly suspended jobs (and not waiting on tty) for bg
> - aknowledge the fact that kill has more uses than to kill jobs. the jobs
>   completion should only work once "%" is entered. "ls /proc" might be used
>   as well as "kill -l" for other cases.

Too bad both of those would require separate but very similar functions.
Or is there some way to get at the name of the command that caused the
completion to be selected?

(Also too bad that using /proc isn't portable. `ps` output is better, but
only marginally.)

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com



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