Created
September 21, 2016 12:45
-
-
Save marzocchi/d25ba65d403a27f9929c6b05c74a2fe2 to your computer and use it in GitHub Desktop.
Delete GIT branches using a dialog with multiple selection
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
#!/usr/bin/env zsh | |
set -e | |
ANSWER_FILE=$(mktemp) | |
function ask() { | |
local -a choices | |
for branch in $(git branch); do | |
choices+="$branch $branch off" | |
done | |
dialog --separate-output --checklist "Choose one or more branches" 10 0 0 -- ${=choices} 2> ${ANSWER_FILE} | |
local exit_status=$? | |
} | |
ask | |
clear | |
read REPLY\?"Really delete: $(cat ${ANSWER_FILE} | xargs) (y/N): " | |
if [[ "$REPLY" != "y" ]]; then | |
exit 1 | |
fi | |
for i in `cat "${ANSWER_FILE}"`; do | |
git branch -D "$i" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment