Fixing IRB autocompletion on OSX

Ruby — Dillon @ 11:25 am

Using macports version of ruby (and irb), I noticed that the lovely and wonderful tab autocompletion wasn’t working:

$ irb --simple-prompt
>> "foo".cap (The tab key! It does nothing!)

So you can see that I was hitting tab expecting to see .cap resolve to .capitalize but it did nothing. I’m not quite sure if this has been broken for a long time or forever. On Linux, irb seems to just work. So I found a fix out on the ‘tubes.

sudo gem install bond
$ cat ~/.irbrc
require 'rubygems';
require 'bond';
Bond.start

And now the tab is delicious.

>> "foo".cap [tab]
>> "foo.capitalize
=> "Foo"

Now while you’re at it, might as well get the color going with wirble:
sudo gem install wirble
Add some more lines to .irbrc. Now our .irbrc looks like this:
$ cat ~/.irbrc
require 'rubygems'
require 'wirble'
require 'bond'
Wirble.init
Wirble.colorize
Bond.start

Irb will have color and [tab] now which you can see in the screenshot right there. The colors can be customized in wirble but it seems to be limited to ANSI terminal colors. I wish the terminal would support RGB #html_codes, you could really go crazy and port some of the awesome Textmate themes over to the irb term.

1 Comment »

  1. Did you run into the EditLine issues as well or are you running Readline?

    Comment by Matt Topper — July 11, 2010 @ 10:23 pm

RSS feed for comments on this post. TrackBack URI

Leave a comment

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.
(c) 2012 SQUARISM | powered by WordPress with Barecity