Tab completion and history with irb and script/console
One thing I love about Ruby (and really miss when working in Java) is its interactive command line interpreter irb (or script/console if you’re using Rails). I really wish irb had tab completion and saved history configured by default out of the box. The good news is it’s easy to configure by creating a $HOME/.irbrc file with the following contents:
require 'irb/completion' ARGV.concat [ "--readline", "--prompt-mode", "simple" ] IRB.conf[:EVAL_HISTORY] = 1000 IRB.conf[:SAVE_HISTORY] = 1000 IRB.conf[:HISTORY_FILE] = File::expand_path(”~/.irbhistory”)
Now when I fire up irb or script/console I get full readline support including tab completion (for example type Time:: and hit tab), reverse command search (control-R), and saved command history so when I exit and restart my command history is still there!
December 25th, 2006 at 12:55 pm
amazing… after 30 or so articles on how to compile readline into ruby, this fixed my issue with script/console not loading readline.
Thank you
February 6th, 2007 at 6:41 am
[...] boa notícia é que isso é fácil de configurar criando um arquivo em “$HOME/.irbc” . Veja o código para o conteúdo desse arquivo. Tags: aprenda, Artigos, ruby, Tutoriais O que você achou deste [...]
August 23rd, 2007 at 11:07 pm
I use ruby on rails on linux SUSE 10.1 and script/console failed to launch with an error loading readline. With your file, all is OK now.
Thank you