Last active
January 2, 2016 19:29
-
-
Save coderofsalvation/8350368 to your computer and use it in GitHub Desktop.
find and kill by brett terpstra
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # find and kill by brett terpstra (saving repetitive ps aux + kill -9 ) | |
| fp () { #find and list processes matching a case-insensitive partial-match string | |
| ps Ao pid,comm|awk '{match($0,/[^\/]+$/); print substr($0,RSTART,RLENGTH)": "$1}'|grep -i $1|grep -v grep | |
| } | |
| fk () { # build menu to kill process | |
| IFS=$'\n' | |
| PS3='Kill which process? ' | |
| select OPT in $(fp $1) "Cancel"; do | |
| if [ $OPT != "Cancel" ]; then | |
| kill $(echo $OPT|awk '{print $NF}') | |
| fi | |
| break | |
| done | |
| unset IFS | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment