TIP: Ruby, IRB Auto-Complete

Create/Edit the .irbrc file in your home directory (UNIX users) and add the following code:

IRB.conf[:AUTO_INDENT] = true
IRB.conf[:USE_READLINE] = true
IRB.conf[:LOAD_MODULES] = [] unless IRB.conf.key?(:LOAD_MODULES)
unless IRB.conf[:LOAD_MODULES].include?('irb/completion')
IRB.conf[:LOAD_MODULES] << 'irb/completion'
end

Now, when you are typing commands into IRB, you can hit the “tab” key and it will automatically complete the command for you or display a list of possible commands.

4 Comments »

  1. include said,

    May 20, 2008 @ 7:42 pm

    nice add is:

    require ‘rubygems’
    require ‘wirble’

    IRB.conf[:AUTO_INDENT] = true
    IRB.conf[:USE_READLINE] = true
    IRB.conf[:LOAD_MODULES] = [] unless IRB.conf.key?(:LOAD_MODULES)
    unless IRB.conf[:LOAD_MODULES].include?(’irb/completion’)
    IRB.conf[:LOAD_MODULES] < < ‘irb/completion’
    end

    Wirble.init
    Wirble.colorize

    to get colors on it :P

  2. Vidul said,

    June 9, 2009 @ 4:54 am

    Thanks, both the post and the comment help a lot!

  3. include said,

    June 9, 2009 @ 9:03 am

    Thanks @Vidul :)

  4. MetalElf0 said,

    June 24, 2009 @ 7:57 am

    Thanks for the post, really helpful!

RSS feed for comments on this post · TrackBack URI

Leave a Comment

Related Posts