Created
February 21, 2026 01:32
-
-
Save koteitan/6c6272715911db2789efefb0971dc541 to your computer and use it in GitHub Desktop.
list live-server ports
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
| #!/bin/bash | |
| # List ports that live-server is listening on | |
| pids=$(ps aux | grep 'node.*[l]ive-server' | awk '{print $2}') | |
| if [ -z "$pids" ]; then | |
| echo "No live-server running." | |
| exit 0 | |
| fi | |
| for pid in $pids; do | |
| port=$(ss -tlnp 2>/dev/null | grep "pid=$pid," | awk '{print $4}' | grep -oE '[0-9]+$') | |
| dir=$(readlink -f /proc/$pid/cwd 2>/dev/null) | |
| [ -n "$port" ] && echo "http://localhost:$port $dir" | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment