Skip to content

Instantly share code, notes, and snippets.

@onigra
Created February 7, 2019 06:52
Show Gist options
  • Save onigra/3da6966bfda8b7d6a6614b159abd1a1b to your computer and use it in GitHub Desktop.
Save onigra/3da6966bfda8b7d6a6614b159abd1a1b to your computer and use it in GitHub Desktop.
remote branch checkout
function gcp() {
local res
local branch=$(git branch -a | peco | tr -d ' ')
if [ -n "$branch" ]; then
if [[ "$branch" =~ "remotes/" ]]; then
local b=$(echo $branch | cut -d '/' -f 3-)
res="git checkout -b ${b} ${branch}"
else
res="git checkout ${branch}"
fi
fi
_cool-peco-on-complete "$res"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment