Autocomplete Git commands and Branch names in Terminal on Mac OS X
If you are a user of Git on Mac OS X then sometimes it can become annoying that you cannot autocomplete the Git commands and branch names.
Luckily there is a way to fix this simple problem:
1. First step is to execute this command in your terminal window, this is basically grabbing the ‘git-completion.bash’ script and putting it in your home directory.
curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash -o ~/.git-completion.bash
2. Now add this line to your ‘~/.bash_profile’. This will allow the execution of the git autocomplete script if it present
if [ -f ~/.git-completion.bash ]; then
. ~/.git-completion.bash
fi
3. You can now restart all you terminal windows or just refresh the terminal window you wish to use this script in. To refresh do:
source ~/.bash_profile
You are all done now! Now type ‘git’, ‘space’, ‘tab’, you’ll get a list of all the possibilities. Same thing if you do ‘git checkout tab’ or ‘git checkout first few letters of branch name tab’.
Thanks to Code Warrior for his post:
http://code-worrier.com/blog/autocomplete-git/
Tags: autocomplete, Git