This tip comes from the ever resourceful Brian Cardarella, who has a gist on how to install and set up auto completion with Git. It’s based off of Shawn O. Pierce’s bash completion script. Just what will it do for you?
The contained completion routines provide support for completing:
- local and remote branch names
- local and remote tag names
- .git/remotes file names
- git ‘subcommands’
- tree paths within ‘ref:path/to/file’ expressions
- common —long-options
Installation is really easy: just download/wget/curl the files and put them in your home directory, edit your
.bash_profile and you’re set. Eric Goodwin also has a great writeup of how to pull the script down and install it if you haven’t compiled git from source. He also has found a fantastic article on bash’s various startup files if this is all new to you.
For OSX users, you can also use MacPorts to install the script. Pratik Naik has a really easy way of installing it if you used the
+bash_completion option. If not, it’s probably easier to just deactivate your current version and reinstall it with that option added.
If you know how to accompish this in other shells, comment away or submit a tip!