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

Re: multiple background jobs of the same program



Stefan Monnier <monnier+lists/zsh/workers/news/@tequila.cs.yale.edu> writes:
> Good point, here is a version that should correctly ignore the "(tty input)"
> thingie if present:

I must be stupid, because a much simpler alternative works just as well if not
better:

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


-- Stefan

PS: a few improvements possible:

- 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.



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