Last active
December 28, 2020 00:08
-
-
Save m-tmatma/05b9573ad64ef67eb3662d62bb6d0a20 to your computer and use it in GitHub Desktop.
checkout by peco
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/sh | |
# | |
# please install peco in advance. | |
# | |
# sudo apt install -y peco | |
# | |
coremote () { | |
remotename=`echo $1 | sed -r "s#([^/]+)/.*#\1#"` | |
branchname=`echo $1 | sed -r "s#[^/]+/##"` | |
git branch | grep "..$branchname$" | |
if [ $? = 0 ]; then | |
git checkout $branchname | |
else | |
git checkout -b $branchname $remotename/$branchname | |
fi | |
} | |
alias cor='export -f coremote; coremote $(git branch -r | grep -v "/HEAD" | peco)' | |
colocal () { | |
branchname=`echo $1 | sed -r "s#^../##"` | |
git checkout $branchname | |
} | |
alias col='export -f colocal; colocal $(git branch | peco)' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment