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:
> Thanks much again!  That's _almost_ perfect :)  The only remaining thing is
> that if a job is suspended due to tty output/input, the sed script doesn't
> quite do the right thing (the completion looks like:
> 
> fg %1 ;: tty output) vi foo
> 
> which then gives a parse error if you hit <return> due to the unmatched ')'.
> Oh well, no biggie:)

Good point, here is a version that should correctly ignore the "(tty input)"
thingie if present:

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


-- Stefan



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