Skip to content

Instantly share code, notes, and snippets.

@avegancafe
Created March 23, 2023 14:27
Show Gist options
  • Save avegancafe/0bab39c875338b713c75db37633d9734 to your computer and use it in GitHub Desktop.
Save avegancafe/0bab39c875338b713c75db37633d9734 to your computer and use it in GitHub Desktop.
Fuzzy-find and kill processes
function fkill --description 'Fuzzy-find process and kill it'
set -l fzf_args --reverse --height 40% --no-hscroll -n 8 --ansi --multi
set -l pid
if test (id -u) -eq 0
set pid (ps -f -u $UID | sed 1d | fzf $fzf_args | awk '{print $2}')
else
set pid (ps -ef | sed 1d | fzf $fzf_args | awk '{print $2}')
end
echo $pid
if test "$pid" = ''
return
end
set -l process_name (ps -o command= -p $pid)
log "Killing '$process_name'..."
echo $pid | xargs kill -9
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment