#!/bin/sh # gbd -- interactive git branch deletion with fzf set -eu protected="main master develop" branches=$(git branch --sort=-committerdate | sed 's/^..//' | grep -v "^$(git branch --show-current)$") for p in $protected; do branches=$(echo "$branches" | grep -v "^${p}$" || true) done if [ -z "$branches" ]; then echo "No deletable branches" exit 0 fi selected=$(echo "$branches" | fzf -m \ --header "Select branches to delete (TAB to multi-select)" \ --preview 'git log --oneline --graph --color=always {} | head -20') if [ -n "$selected" ]; then echo "$selected" | while read -r branch; do git branch -d "$branch" 2>/dev/null || echo "Cannot delete $branch (not fully merged, use -D to force)" done fi