Enable Tab Completion in IRB (Ubuntu)

I've wanted to add tab completion to IRB for a while, but when I had tried a tutorial that I found on the Web a few weeks ago, it didn't work for me.

I just found a great Flash video on how to enable tab completion in IRB. I was glad to see that the author of the tutorial was also using Ubuntu, and that the solution is very fast and easy.

Basically, just create a file in your home directory called .irbrc. Add the following two lines and save it:

require 'irb/completion'
IRB.conf[:PROMPT_MODE] = :SIMPLE

The first line enables IRB completion, and the second removes the extra text in the irb prompt.

The irb prompt before:

irb prompt before

The irb prompt after, looking much better:

irb prompt after

To use the tab completion in irb, press TAB twice. Irb will then give you a list of possible completions like this:

irb tab completion on Ubuntu

No votes yet

Comments

Glad you found our video useful :-)

It is great to know that you found the IRB video useful. That was Eric Lake's first contribution to ShowMeDo, we're looking forward to getting more for Ruby to build up a set that is as useful as our 38+ Python video collection.

We'd also welcome videos showing people how to do things in the world of web design, if anyone would like to get involved? We certainly have an appreciative audience just waiting to learn!

Webmaster Tips's picture

Python

Thanks for stopping by. I didn't realize that you had those Python videos too. I'm starting another blog soon just about Python so I will check them out.

Syndicate content