Last active
August 8, 2016 03:58
-
-
Save melbourne2991/441158c98f0ca996c0f143942f17c0c0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# --Helper Functions-- | |
# Finds PIDs using port | |
pidport() { | |
if [ -z $1 ]; | |
then echo "pidport requires <port>"; | |
return 1; | |
fi | |
lsof -n -i:$1 | grep LISTEN | while read line; | |
do | |
cols=($line); | |
echo -n "process: ${cols[0]}, pid: ${cols[1]}, kill? (y/n) "; | |
read answer </dev/tty; | |
if [[ "$answer" == y* ]]; | |
then kill "${cols[1]}"; echo "done."; | |
fi | |
done; | |
} | |
export -f pidport | |
#shorthand cd then ls | |
cdd() { | |
cd $1; | |
ls; | |
} | |
export -f cdd | |
# Finds PIDs using port (ZSH Compatible) | |
pidport() { | |
if [ -z $1 ]; | |
then echo "pidport requires <port>"; | |
return 1; | |
fi | |
lsof -n -i:$1 | grep LISTEN | while read c1 c2 c3; | |
do | |
echo -n "process: $c1, pid: $c2, kill? (y/n) "; | |
read answer </dev/tty; | |
if [[ "$answer" == y* ]]; | |
then kill "$c2"; echo "done."; | |
fi | |
done; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment