Search code examples
linuxbackgroundzshjobs

How to kill all background processes in zsh?


As in the title - how to kill all background processes in zsh?


Solution

  • alias killbg='kill ${${(v)jobstates##*:*:}%=*}'
    

    . It is zsh, no need in external tools.

    If you want to kill job number N:

    function killjob()
    {
        emulate -L zsh
        for jobnum in $@ ; do
            kill ${${jobstates[$jobnum]##*:*:}%=*}
        done
    }
    killjob N