irb

On Ubuntu, edgy, irb doesn’t have tab completion out of the box. Create a file called ~/.irbrc and put in it:


require 'irb/completion'

Next time you use irb you can hit tab twice to see what methods are available on an object or what commands start with a letter.


irb(main):004:0> require 'hpricot'
irb(main):004:0> require 'open-uri'
irb(main):004:0> doc = Hpricot(open('http://some.url.com/'))
irb(main):004:0> doc.[tab][tab]
Display all 121 possibilities? (y or n)
doc.filter[:contains]
doc.find_element
doc.pretty_print_instance_variables
doc.__id__
doc.filter[:empty]
doc.freeze
...

**EDIT** typo, thanks Melissa! **EDIT**

About Nathan Powell

I am a middle aged technologist freak-ball.
This entry was posted in programming. Bookmark the permalink.

3 Responses to irb

  1. mgoss says:

    Thanks, this is useful and I didn’t know about it.

    I just tried on my Gentoo install and it didn’t have it either.

    I also think you mean “~/.irbrc”, which worked for me, but not your “~/.irbc”. You can also do it from the command line, I found: “irb -r irb/completion”.

    The only thing that I don’t like about it is it no longer tab completes directories/files, which was useful when I would want to load a bunch of my files/classes/code to test some stuff. Oh well.

  2. Doug says:

    Integrated Routing and Bridging? Oh sorry – too much Cisco recently.

  3. Melissa, good call that is a typo.

    Doug, heh, must be! :)