Bash Completion, Along with SVN and Git Tab Completion


Time is precious. I installed these utilities to save some of it:

I install bash-completion via MacPorts on my Macs.

sudo port install bash-completion

I then saved this svn-completion script to locally, and did a sudo cp:

sudo cp bash_completion /opt/local/etc/bash_completion.d/svn-completion.sh

Note: “bash_completion” is the file linked on “svn-completion script“. I hope that avoids confusion.

Last but not least, I then installed the git-completion script. I first checked the version of Git I have via MacPorts which happens to be 1.6.0.5. ((Got it by using git version.)) I then saved and untarred the Git tarball of the version I have locally. Then did another sudo cp of the actual git-completion script to the same directory where my svn-completion.sh is located at:

sudo cp git-1.6.0.5/contrib/completion/git-completion.bash /opt/local/etc/bash_completion.d/git-completion.sh

After that, I added the following to to my .profile (or .bash_profile):

# for bash-completion
if [ -f /opt/local/etc/bash_completion ]; then
    . /opt/local/etc/bash_completion
fi
source /opt/local/etc/bash_completion.d/svn-completion.sh
source /opt/local/etc/bash_completion.d/git-completion.sh

Either restart your Terminal, or re-execute your .profile, and that would do it.

For more info on Git completion, check out this article by Kamal Fariz (bitfluent).