diff --git a/configs/zsh/functions.zsh b/configs/zsh/functions.zsh index 6b5698b..977a91b 100644 --- a/configs/zsh/functions.zsh +++ b/configs/zsh/functions.zsh @@ -2,4 +2,5 @@ source $(dirname "$0")/functions/co.zsh; source $(dirname "$0")/functions/fx.zsh; source $(dirname "$0")/functions/start.zsh; source $(dirname "$0")/functions/wp.zsh; -source $(dirname "$0")/functions/y.zsh; \ No newline at end of file +source $(dirname "$0")/functions/y.zsh; +source $(dirname "$0")/functions/fp.zsh; \ No newline at end of file diff --git a/configs/zsh/functions/fp.zsh b/configs/zsh/functions/fp.zsh new file mode 100644 index 0000000..4e894f6 --- /dev/null +++ b/configs/zsh/functions/fp.zsh @@ -0,0 +1,29 @@ +#Helps stop processes which use ports + +function fp(){ + + PORT=$1; + + if [ "$(which lsof)" = "lsof not found" ]; then + echo "lsof not installed" + else + PIDS="$(lsof -t -i:$PORT)" + + AMOUNT=$(wc -w<<<$PIDS); + + if [ $AMOUNT = 0 ]; then + + echo "No processes use port $PORT"; + + else + + echo "Killing $AMOUNT process(es) using port $PORT"; + + echo "$PIDS" | while IFS= read -r pid ; do + kill -9 $pid; + done + + fi + fi + +} \ No newline at end of file