Skip to content

Instantly share code, notes, and snippets.

@takezoe
Created August 26, 2017 07:01
Show Gist options
  • Save takezoe/a48e987b6ebce2969a9c9cd96521c184 to your computer and use it in GitHub Desktop.
Save takezoe/a48e987b6ebce2969a9c9cd96521c184 to your computer and use it in GitHub Desktop.
function peco-git-checkout() {
local BRANCH=`git branch -a | peco`
if [[ -z "$BRANCH" ]]; then
return
fi
if [[ "$BRANCH" =~ remotes/([^/]*)/(.*) ]]; then
git checkout -b ${BASH_REMATCH[2]} ${BASH_REMATCH[1]}/${BASH_REMATCH[2]}
else
git checkout $BRANCH
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment