bash command completion for rake

Posted by Tim Connor Wed, 10 Oct 2007 03:29:00 GMT

I’ve written about improved bash completion in OS X before, but when setting up a iMac at my new job (more on that later), I couldn’t recall what I did for tab completion of rake tasks (which is really nice to have if you do much rails work). This time around, I just dropped Lee Marlow’s Rake Command Completion Using Rake into a scripts folder in my home directory, named it rake-completion.rb, and added


complete -C /Users/timconnor/scripts/rake-completion.rb -o default rake

into my .profile (or .bashrc or .bash_login, etc).

If you use one of the ruby completion scripts (like Lee’s) make sure not to drop it in your bash_completion auto-added folder (/opt/local/etc/bash_completion.d/) as that will choke, expecting a bash script, instead of a ruby one.

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.