Last active
April 24, 2019 05:01
-
-
Save pikatenor/32816a9fa7d3ff3b051eaa3a31fa7513 to your computer and use it in GitHub Desktop.
git の ブランチを選んで消したり出したりするやつ
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 -eo pipefail | |
RESTORE='\033[00m' | |
RED='\033[31m' | |
GREEN='\033[32m' | |
cmd=${1:-checkout} | |
option=$2 | |
case $cmd in | |
delete ) git_cmd="branch --delete" ;; | |
fetch ) git_cmd="fetch origin" ;; | |
merge ) git_cmd="merge" ;; | |
checkout ) git_cmd="checkout" ;; | |
* ) git_cmd="checkout" ;; | |
esac | |
echo | |
echo -e "You are now on $GREEN$(git branch | grep \* | cut -d ' ' -f2)$RESTORE" | |
echo | |
branches=$(git branch | cut -c 2-) | |
echo -e "Select branch to $RED$git_cmd $option$RESTORE" | |
select branch in $branches | |
do | |
git $git_cmd $option $branch | |
exit 0 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment