mirror of
https://github.com/jarun/nnn.git
synced 2024-11-28 05:41:31 +00:00
1afdd48f5d
* nuke: use macOS open when GUI enabled * nuke: use is_mac function to test for macOS This is consistent with how the imgur plugin does detection. * Add macOS open command to plugins * pskill: only execute if input is non-empty
36 lines
746 B
Bash
Executable file
36 lines
746 B
Bash
Executable file
#!/usr/bin/env sh
|
|
|
|
# Description: Fuzzy list and kill a (zombie) process by name
|
|
#
|
|
# Dependencies: fzf, ps
|
|
#
|
|
# Note: To kill a zombie process enter "zombie"
|
|
#
|
|
# Shell: POSIX compliant
|
|
# Author: Arun Prakash Jana
|
|
|
|
printf "Enter process name ['defunct' for zombies]: "
|
|
read -r psname
|
|
|
|
# shellcheck disable=SC2009
|
|
if ! [ -z "$psname" ]; then
|
|
if which sudo >/dev/null 2>&1; then
|
|
sucmd=sudo
|
|
elif which doas >/dev/null 2>&1; then
|
|
sucmd=doas
|
|
else
|
|
sucmd=: # noop
|
|
fi
|
|
|
|
if which fzf >/dev/null 2>&1; then
|
|
fuzzy=fzf
|
|
else
|
|
exit 1
|
|
fi
|
|
|
|
cmd="$(ps -ax | grep -iw "$psname" | "$fuzzy" | sed -e 's/^[ \t]*//' | cut -d' ' -f1)"
|
|
if [ -n "$cmd" ]; then
|
|
$sucmd kill -9 "$cmd"
|
|
fi
|
|
fi
|