Created
February 1, 2026 23:08
-
-
Save jordiup/252643e33d0d4fb66761ea10d94efc67 to your computer and use it in GitHub Desktop.
port kill ~/.zshrc script
This file contains hidden or 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
| pk() { | |
| if [ -z "$1" ]; then | |
| echo -e "💀 \033[31mSelect ports to kill:\033[0m" | |
| echo " 1) 3000" | |
| echo " 2) 3001" | |
| echo " 3) both" | |
| read -r "choice?> " | |
| local ports=() | |
| case "$choice" in | |
| 1) ports=(3000) ;; | |
| 2) ports=(3001) ;; | |
| 3|all|both) ports=(3000 3001) ;; | |
| *) echo "Cancelled"; return 0 ;; | |
| esac | |
| for port in "${ports[@]}"; do | |
| lsof -ti :"$port" | xargs kill -9 2>/dev/null && echo "Killed process on port $port" || echo "No process on port $port" | |
| done | |
| return 0 | |
| fi | |
| lsof -ti :"$1" | xargs kill -9 2>/dev/null | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment