Skip to content

Instantly share code, notes, and snippets.

@joshschmelzle
Created August 14, 2024 00:26
Show Gist options
  • Save joshschmelzle/5678cd35dffa8da119cfb0a8962a69f3 to your computer and use it in GitHub Desktop.
Save joshschmelzle/5678cd35dffa8da119cfb0a8962a69f3 to your computer and use it in GitHub Desktop.
One liners

macOS/BSD specific

Thanks @seldo and @NurmiWilliam

sudo lsof -iTCP -sTCP:LISTEN -n -P | awk 'NR>1 {print $9, $1, $2}' | sed 's/.*://' | sort -u | while read port process pid; do echo "Port $port: $(ps -p $pid -o command= | sed 's/^-//') (PID: $pid)"; done | sort -n

git-sweep.sh

Thanks @_eseidel

#!/bin/sh
git fetch -p && for branch in $(git for-each-ref --format '%(refname) %(upstream:track)' refs/heads | awk '$2 == "[gone]" {sub("refs/heads/", "", $1); print $1}'); do git branch -D $branch; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment