Skip to content

Instantly share code, notes, and snippets.

@Olical
Created June 17, 2011 15:34
Show Gist options
  • Select an option

  • Save Olical/1031652 to your computer and use it in GitHub Desktop.

Select an option

Save Olical/1031652 to your computer and use it in GitHub Desktop.
Git branch / tag/ remote / command terminal completion. Drop it into your bash profile
_complete_git() {
if [ -d .git ]; then
branches=`git branch -a | cut -c 3-`
tags=`git tag`
remotes=`git remote`
commands="add bisect branch checkout clone commit diff fetch grep init log merge mv pull push rebase reset rm show status tag stash pop"
cur="${COMP_WORDS[COMP_CWORD]}"
COMPREPLY=( $(compgen -W "${branches} ${tags} ${remotes} ${commands}" -- ${cur}) )
fi
}
complete -F _complete_git git checkout
@ciacci1234

Copy link
Copy Markdown

I know this was made a long time ago, but I just discovered it and it resolved a small, but palpable pain point of mine. Thank you 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment