Think In Geek

In geek we trust

Customizing IRB

While developing a Ruby application or while learning ruby, one of the things you must use is IRB (interactive ruby). As in its man page is said “irb is a tool to execute interactively ruby expressions read from stdin.”. In this tool you can type and execute directly ruby code. It’s very useful but like most other programs like ViM (Vi IMproved) the real power is its customization.

Here I post my .irbrc and to make things clear there are some explanations on each line.

# autocompletion of methods when pressing TAB
require 'irb/completion'
# Wirble is a plugin to colorize your irb, it's installed from a gem (gem install -y wirble)
require 'rubygems'
require 'wirble'
 
# Make use of readline library
ARGV.concat [ "--readline" ]
 
# autoindent of code while typing it
IRB.conf[:AUTO_INDENT]=true
 
# wirble initializations
Wirble.init
Wirble.colorize

As I said before, IRB is very powerful and a proof is that in Ruby Lang they encourage you to try ruby in your browser with an embedded IRB.

Also in rails the console for debugging your application is an irb instance preloaded with all rails configuration. In RailsCasts there is a screencast that shows you some tricks about it.

Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn

, ,

Leave a Reply

Your email address will not be published. Required fields are marked *