-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnuke
executable file
·27 lines (21 loc) · 828 Bytes
/
nuke
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env bash
## By Davoud Arsalani
## https://github.com/davoudarsalani/scripts
## https://github.com/davoudarsalani/scripts/blob/master/nuke
## https://raw.githubusercontent.com/davoudarsalani/scripts/master/nuke
## https://davoudarsalani.ir
## https://revelry.co/terminal-workflow-fzf/
## https://github.com/junegunn/fzf/wiki/examples
source "$HOME"/main/scripts/gb
IFS=$'\n'
if (( UID > 0 )); then
readarray -t processes < <(ps -f -u "$UID")
else
readarray -t processes < <(ps -ef)
fi
process="$(pipe_to_fzf "${processes[@]}")" && wrap_fzf_choice "$process" || exit 37
process="$(printf '%s\n' "$process" | awk '{print $2}')"
kill_prompt="$(get_single_input "kill ${process}?")" && printf '\n'
case "$kill_prompt" in
y ) [ "$process" ] && printf '%s\n' "$process" | xargs kill -9 ;;
esac