Created
October 30, 2019 10:35
-
-
Save remyoudemans/e846f982e9b114690b5dacc38415639d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -euo pipefail | |
IFS=$'\n\t' | |
green='\033[0;32m' | |
NC='\033[0m' # No Color | |
branches=() | |
eval "$(git for-each-ref --shell --format='branches+=(%(refname))' refs/heads/)" | |
for branch in "${branches[@]}"; do | |
branch="$(echo $branch | cut -d/ -f3-)" | |
echo -e "Branch to delete: $green$branch$NC" | |
read -p "Delete? (y/N)" -n 1 | |
if [[ $REPLY == "y" ]]; then | |
echo | |
echo "...................deleting" | |
git branch -d $branch | |
else | |
echo "skipping" | |
fi | |
echo | |
done | |
echo 'All done!' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment