▲ | npretto 7 hours ago | |
a couple of prompts of claude code gave me this, works well enough, but while I agree that this is sometimes useful, it may indeed better served by a couple of aliases in the terminal ``` #!/bin/bash # SwiftBar Port Monitor # Monitors processes on TCP ports 2000-6000 # Menu bar title echo " Ports" echo "---" # Get processes listening on TCP ports 2000-6000 processes=$(lsof -iTCP:2000-6000 -sTCP:LISTEN -n -P 2>/dev/null | awk 'NR>1 {print $2 "|" $1 "|" $9}' | sort -t'|' -k3 -n) if [ -z "$processes" ]; then echo "No processes found on ports 2000-6000" exit 0 fi # Process each line while IFS='|' read -r pid name port_info; do if [ -n "$pid" ] && [ -n "$name" ] && [ -n "$port_info" ]; then # Extract port number from format like :3000 port=$(echo "$port_info" | sed 's/.://')
done <<< "$processes"# Refresh option echo "---" echo "Refresh | refresh=true |