Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
My first zsh function
- X-seq: zsh-users 6419
- From: Skye Poier <skye@xxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: My first zsh function
- Date: Mon, 28 Jul 2003 11:20:50 -0700
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
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