Merge branch 'main' of https://github.com/jim-fx/.dotfiles into main

This commit is contained in:
2021-01-29 13:56:05 +01:00
5 changed files with 52 additions and 16 deletions

View File

@ -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
}