Script/console history

When you quit script/console you lose your command history. What
would it take to get get that command history to persist? I wouldn’t
mind working on it if somebody had a good suggestion as to how to
achieve that and if it was an acceptable solution to the core team.

D :slight_smile:

Third Replicator,

If you are using some Linux system then you are safe. I use Ubuntu
myself. I
was tied of rewriting everything I put on the console too. So I with
little effort and help from friends, I made a small hack. Now, I have a
simple script that helps me keep track of command-line history for both

  • and script/console.

Follow the steps below:

  • create .irbrc file in your home directory :

ceekays@kanjedza:~$ touch .irbrc

  • open .irbrc using your preferred text editor (I prefer
    based ones: vi, vim, gvim), add the following lines and* save*:

*# This script saves and retrieves up to 600 lines of

command-line history in both irb and script/console

of a **Rails’s project. (UP and DOWN ARROW keys to navigate)

In addition, it supports auto-completion.(Use the

TAB key to get auto-complete suggestions).*

*# *
*# :SAVE_HISTORY keeps the maximum number of lines to be saved

customize this to suite the amount of history would

like to retrieve

:HISTORY_FILE keeps the file name where the

history is kept. In this case it is saved in the

home directory of the current user

i.e in the same directory where as this .irbrc file

ARGV.concat [ “–readline”, “–prompt-mode”, “simple” ]
require ‘irb/completion’
require ‘irb/ext/save-history’
require ‘rubygems’
require ‘map_by_method’
require ‘wirble’
require ‘pp’

IRB.conf[:AUTO_INDENT]= true
IRB.conf[:SAVE_HISTORY] = 600
IRB.conf[:HISTORY_FILE] = “#{ENV[‘HOME’]}/.irb-save-history”


Once you have this, you will be able to retrieve script/console’s
command-line history up to 600 lines. Please inform me if doesn’t work.
would be very happy to get as much input as possible.

I think Sprite will also find this useful.
P/S: I am not sure if I have violated the forum rules by adding an
attachment. If so, forgive me and inform me how best I can send files


Software Developer | Baobab Health Trust (

Cell: +265 999 465 137 | +265 881 234 717

“Many people doubt open source software and probably don’t realize that
there is an alternative… which is just as good…” – Kevin Scannell

Very nice! It works on my Mac 10.6, Ruby 1.9.1 via RVM, Rails 2.3.8.
I had to install a couple of the required gems. Do you have it on

D :slight_smile:

On Wed, Aug 11, 2010 at 3:54 AM, Edmond K.