Git tab autocomplete on OSX 10.11 El Capitan

By | January 6, 2016

In Ubuntu, this comes out of the box but in terminal on OSX a few extra steps are required to get this to work. It is a bit of a hassle figuring out what needs to be done, but once you know, it literally takes 10 seconds.

Step 1: Download auto completion script:

>> cd ~
>> curl -O https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash

This downloads the auto completion script.

Step 2: Update .bash_profile

>> echo "source ~/git-completion.bash" >> .bash_profile

This adds an extra line into your .bash_profile

That is it! Easy as.

Notes:

  • You may need to restart terminal.
  • You want to curl the “raw” version of this file:¬†https://github.com/git/git/blob/master/contrib/completion/git-completion.bash so add raw as a subdomain (raw.github.com/etc….) and you’ll see the redirect.
  • The -O flag in curl means to download it as a file. Otherwise you’ll see the file echoed out in the terminal.

References:

  • https://git-scm.com/book/en/v1/Git-Basics-Tips-and-Tricks
  • http://www.joshstaiger.org/archives/2005/07/bash_profile_vs.html

2 thoughts on “Git tab autocomplete on OSX 10.11 El Capitan

Leave a Reply

Your email address will not be published. Required fields are marked *