Skip to content

Instantly share code, notes, and snippets.

@jonathanfann
Last active July 29, 2026 23:49
Show Gist options
  • Select an option

  • Save jonathanfann/f6eedb35eb160a53627b1fed55772925 to your computer and use it in GitHub Desktop.

Select an option

Save jonathanfann/f6eedb35eb160a53627b1fed55772925 to your computer and use it in GitHub Desktop.
Git Prune zsh choice
## this can be in your .zshrc
function pruneBranches() {
echo "thinkin..."
git fetch --prune
local lostInTheWoods=$(git branch -vv | grep 'gone]' | awk '{print $1}')
if [[ -z "$lostInTheWoods" ]]; then
echo "\nain't nuthin to prune"
return
fi
if read -q "choice?going to prune...ok? [y/N]"; then
echo "$lostInTheWoods"
else
echo
echo "'$choice' not 'y' so not pruning."
fi
}
alias doPrune="pruneBranches"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment