Skip to content

Instantly share code, notes, and snippets.

@mikker
Created May 23, 2013 11:52
Show Gist options
  • Save mikker/5635538 to your computer and use it in GitHub Desktop.
Save mikker/5635538 to your computer and use it in GitHub Desktop.
Checkout new (or existing) branch of name $1 -- with completion
nb() {
if [[ $(git branch | tr -d '* ' | grep "$1") != "" ]]; then
git checkout $1
else
git checkout -b $1
fi
}
_nb() { reply=($(git branch | tr -d '* ' | xargs echo)) }
compctl -K _nb nb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment