Skip to content

Instantly share code, notes, and snippets.

@cartok
Last active September 20, 2024 09:29
Show Gist options
  • Save cartok/a08c6c09edbccf7984bf0721a0e1f202 to your computer and use it in GitHub Desktop.
Save cartok/a08c6c09edbccf7984bf0721a0e1f202 to your computer and use it in GitHub Desktop.
[cli] kill-port
function kill-port() {
ss --numeric --tcp --listening --processes --resolve --no-header --no-queues --oneline \
| grep "pid=" \
| sd '^\w+ +(?P<HOST>[^:]+):(?P<PORT>\d+) [^"]+"(?P<NAME>[^"]+)",pid=(?P<PID>\d+).*\n?' '$NAME: $HOST:$PORT [$PID]\n' \
| fzf --prompt="Select to kill: " \
| sd '[^\[]+\[(\d+)\]' '$1 ' \
| xargs --no-run-if-empty kill -15
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment