function fkill --description "Fuzzy kill processes" # # Signal Numbers: # # 1 HUP (hang up) # 2 INT (interrupt) # 3 QUIT (quit) # 6 ABRT (abort) # 9 KILL (non-catchable, non-ignorable kill) # 14 ALRM (alarm clock) # 15 TERM (software termination signal) # set --local fkill_uid (id -u) set --local fkill_pid set --local fkill_procs if contains -- '--tcp' $argv set fkill_pid (lsof -Pwni tcp | sed 1d | eval "fzf --multi --prompt='[kill:tcp] '" | awk '{print $2}') else if test $fkill_uid -eq 0 set fkill_procs (ps -ef | tail -n +2 | string collect) else set fkill_procs (ps -f -u $fkill_uid | tail -n +2 | string collect) end set fkill_pid (echo $fkill_procs | eval "fzf --multi --prompt='[kill:process] ' --preview='ps -p {2}' --preview-window='down:3'" | awk '{print $2}') end if test (count $fkill_pid) -gt 0 echo $fkill_pid | xargs kill -9 end end