From 565f3ec7ce2e7147081f755350073c267fb585b3 Mon Sep 17 00:00:00 2001 From: Patrick Spek Date: Thu, 7 Nov 2019 09:06:41 +0100 Subject: Add bc for cleaning branches in git --- .config/git/config | 1 + .local/bin/git-branch-cleaning | 63 ------------------------------------------ 2 files changed, 1 insertion(+), 63 deletions(-) delete mode 100755 .local/bin/git-branch-cleaning diff --git a/.config/git/config b/.config/git/config index 1f4dd13..0f811e4 100644 --- a/.config/git/config +++ b/.config/git/config @@ -1,6 +1,7 @@ [alias] a = add b = branch + bc = branch-cleanup c = commit ca = commit --amend --reset-author co = checkout diff --git a/.local/bin/git-branch-cleaning b/.local/bin/git-branch-cleaning deleted file mode 100755 index 8c728be..0000000 --- a/.local/bin/git-branch-cleaning +++ /dev/null @@ -1,63 +0,0 @@ -#! /usr/bin/env sh - -main() -{ - # Handle opts - opts "$@" - shift "$OPTS" - unset OPTS - - # Show help - [ "$OPT_HELP_ONLY" ] && usage && exit 0 - - # Get a list of branches - buffer=$(mktemp) - - git branch --merged \ - | awk '{ print $NF }' \ - | grep -Ev "^master$" \ - > "$buffer" - - printf "Going to remove the following %s branches:\n" "$(wc -l < "$buffer")" - cat -- "$buffer" - - printf "\n^C to cancel...\n" - read - - while read -r branch - do - git branch -D -- "$branch" - done < "$buffer" -} - -opts() -{ - OPTS=0 - - while getopts ":h" opt - do - case "$opt" in - h) OPT_HELP_ONLY=1 ;; - *) - printf "Invalid option passed: %s\n" "$OPTARG" >&2 - ;; - esac - done - - unset opt -} - -usage() -{ - cat <