Superior bash tab completion in OS X

Posted by Tim Connor Fri, 23 Mar 2007 03:47:00 GMT

As a precursor to my upcoming subversion URL completion (I’m still working on the patch), I’m posting about the really cool prerequisite, bash_completion. This is improved, over what is included by default in OS X, extensible tab completion. It does things like limiting options based on the cmd (only listing directories for the “cd” command") and hostname completion for ssh. It also allows for customizable completion for any command, which is the basis of the forthcoming URL completion.

Since it’s not included in the base OS X install, you need to install it yourself. You could go about this a variety of ways, but I went the DarwinPorts route. After installing Xcode, and DarwinPorts, and then using that to install bash_completion (all actually pretty easy), I sourced the file in my .bash_login

source  /opt/local/etc/bash_completion

I’d recommend dropping the most up to date subversion bash_completion script into the bash_completion.d and it will overwrite the default behavior.

Leave a comment