Last active
December 20, 2015 13:48
-
-
Save chadwhitacre/6141081 to your computer and use it in GitHub Desktop.
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
# This adds tab completion of git branch names (including remotes) to several | |
# git-related bash aliases I have set up: | |
# | |
# co git checkout | |
# gb git branch | |
# gm git merge | |
# | |
# | |
# Bugs: | |
# | |
# When I tab-complete the empty string I get a directory listing plus the | |
# remotes. I would prefer to just have all branches. | |
# | |
# | |
# References: | |
# | |
# https://raw.github.com/django/django/master/extras/django_bash_completion | |
# http://fahdshariff.blogspot.com/2011/04/writing-your-own-bash-completion.html | |
_branch_names() | |
{ | |
local cur=${COMP_WORDS[COMP_CWORD]} | |
COMPREPLY=( $(compgen -W "`gb` `gb -r`" -- $cur) ) | |
} | |
complete -F _branch_names co | |
complete -F _branch_names gb | |
complete -F _branch_names gm |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment