Skip to content

Instantly share code, notes, and snippets.

@koteitan
Created February 21, 2026 01:32
Show Gist options
  • Select an option

  • Save koteitan/6c6272715911db2789efefb0971dc541 to your computer and use it in GitHub Desktop.

Select an option

Save koteitan/6c6272715911db2789efefb0971dc541 to your computer and use it in GitHub Desktop.
list live-server ports
#!/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