Fix for irb. backspace and arrow keys doesn’t work!

It sounded quite unnatural when I found the backspace and left/right arrow keys in irb doesn’t work straight away as expected on my linux (ubuntu) box. As usual, I had to go in search for the cause and solution. After bit of googling I fell on a right blogpost. The problem/fix explained was exactly same and that fix worked for me.

In summary, do the following steps to get your backspace and arrow keys working on irb.

sudo apt-get install libreadline5 libreadline5-dev

Now go to your ruby source. In my case it was ruby-1.8.6-p399/ext/readline and execute the following steps.

ruby extconf.rb
make
sudo make install

I felt bad writing this blog, as I was actually back referencing on someone else’s blogpost. But I wanted to have the details in my blog so that I could cross reference these issues easily in the future.

But for a very clear understanding on the reason for the problem and solution to this fix, please do visit the original blogpost which is right here.

http://expressica.com/2007/07/11/how-to-make-arrow-keys-working-in-irb-in-linuxubuntu/

Colorize and use Tab Completion in irb

Just to add more value to this post, I am including the following link as well which tells you how to set up and use ‘Wrible’ library to get syntax coloring and tab completion features in irb.

http://www.rubyinside.com/wirble-tab-completion-and-syntax-coloring-for-irb-336.html

In summary do the following:

sudo gem install wirble

Edit ~/.irbrc file to include the following lines.
Note: If you couldn’t find the file, create a new one with the name, .irbrc under your home folder.
————————————————————
require ‘rubygems’
require ‘wirble’
Wirble.init
Wirble.colorize

————————————————————
For changing the syntax coloring or for detailed customization of Wirble, checkout the following link:

http://pablotron.org/software/wirble/README

Advertisements

About this entry