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

My first zsh function



Not very 3L337 but it works :)
- Skye


# Killer app.
pskill()
{
        local signal="HUP"
        if [[ $1 == "" || $3 != "" ]]; then
                print "Usage: pskill search_term [signal]" && return 1
        fi
        [[ $2 != "" ]] && signal=$2
        set -A pids $(command ps -wwaux | grep $1 | grep -v "grep $1" | \
                        awk '{ print $2 }')
        if [[ ${#pids} -lt 1 ]]; then
                print "No matching processes for $1" && return 1
        fi
        if [[ ${#pids} -gt 1 ]]; then
                print "${#pids} processes matched: $pids"
                read -q "?Kill all? [y/n] " || return 0
        fi
        if kill -$signal $pids; then
                echo "Killed $1 pid $pids with SIG$signal"
        fi
}



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