As in the title - how to kill all background processes in zsh?
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