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

Re: Problems with zsh's job control and running jobs



On Thu, 2 Sep 2010 15:47:47 +0200
Haakon Riiser <haakon.riiser@xxxxxxxxxx> wrote:
> If not, is it possible to make "&" disown jobs by default?

I got this to work.  It assumes your zsh is recent enough that (i) you have
hook functions and the add-zsh-hook function --- else you need to use
precmd (ii) "jobs" works in the left hand side of a pipeline --- else
you need to use a temporary file.

precmd_disown() {
  emulate -L zsh
  setopt extendedglob
  local job match mbegin mend

  jobs | while read job; do
    if [[ $job = \[(#b)([[:digit:]]##)\]*running* ]]; then
      disown %$match[1]
    fi
  done
}
autoload -U add-zsh-hook
add-zsh-hook precmd precmd_disown

-- 
Peter Stephenson <pws@xxxxxxx>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom



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