From d9a52f698f6f646b7e9028e23cefc9ed4f051216 Mon Sep 17 00:00:00 2001 From: MohamedElsiddig Date: Mon, 12 Aug 2019 22:51:09 +0200 Subject: [PATCH] Added new plugin fkill-cli --- plugins/available/fkill-cli.plugin.sh | 34 +++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 plugins/available/fkill-cli.plugin.sh diff --git a/plugins/available/fkill-cli.plugin.sh b/plugins/available/fkill-cli.plugin.sh new file mode 100755 index 00000000..b9e60603 --- /dev/null +++ b/plugins/available/fkill-cli.plugin.sh @@ -0,0 +1,34 @@ +#!/bin/bash +cite about-plugin +about-plugin 'Fabulously kill processes in intractive way using fuzzy finder' + + +function fkill(){ +if [[ `which fzf` ]] + then + fuzzy_command=fzf +elif [[ `which fzy` ]] + then + fuzzy_command=fzy + else + fuzzy_command="" +fi +if [[ ! -z $fuzzy_command ]] + then + process=`ps -A | awk '{print $1 "\t" $4}' | $fuzzy_command --prompt=Running\ processes: | awk '{print $1}'` + if [[ ! -z $process ]] + then + process_name=`ps -p $process -o comm=` + kill -9 $process + echo "" + echo -e ${echo_bold_green} ✔${echo_bold_yellow} Process $process_name [ id = $process ] were killed successfully${echo_normal} + else + : + fi + else + echo "" + echo -e ${echo_bold_red} ✘${echo_bold_yellow} You Dont have a fuzzy finder command in your path please download one${echo_normal} + +fi + +}