zsh-users
 help / color / mirror / code / Atom feed
* My first zsh function
@ 2003-07-28 18:20 Skye Poier
  0 siblings, 0 replies; only message in thread
From: Skye Poier @ 2003-07-28 18:20 UTC (permalink / raw)
  To: zsh-users

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
}


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-07-28 18:21 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-07-28 18:20 My first zsh function Skye Poier

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).