Created
April 28, 2019 18:20
-
-
Save YanhaoYang/637ffe40227ff3f8f7f777df0470cc9e to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
delete_branches () { | |
branches=($(git branch | sed 's/*//g')) | |
element_count=${#branches[@]} | |
selected_branches=() | |
echo "Select branches:" | |
for br in "${branches[@]}" | |
do | |
echo "Delete $br ? y/(n)" | |
read -n 1 -s yn | |
if [ "$yn" == "y" ]; then | |
selected_branches+=($br) | |
fi | |
done | |
echo "Deleting following branches:" | |
for br in "${selected_branches[@]}" | |
do | |
echo "$br" | |
done | |
read -n 1 -s -p "y/(n)?" yn | |
echo | |
if [ "$yn" == "y" ]; then | |
for br in "${selected_branches[@]}" | |
do | |
git branch -D $br | |
done | |
echo "Done." | |
else | |
echo "Aborted." | |
fi | |
} | |
delete_branches |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment