How To – Persist Rails or IRB Console Command History After Exit

Sick of not having Ubuntu rails or irb terminal not saving your command history after exiting the console?  Try this little trick to fix it up!

Append into your ~/.irbrc the following

require ‘irb/ext/save-history’
IRB.conf[:SAVE_HISTORY] = 200
IRB.conf[:HISTORY_FILE] = “#{ENV['HOME']}/.irb-history”
require ‘irb/ext/save-history’IRB.conf[:SAVE_HISTORY] = 200IRB.conf[:HISTORY_FILE] = “#{ENV['HOME']}/.irb-history”

You will notice the extra bit at the top of my ~/.irbrc, that makes sure that SQL is outputted as I type commands.  Good for debugging.

Now enjoy your rails history!

Posted on September 14, 2010 at 11:46 am by Jordan Carter · Permalink
In: How To, Ruby on Rails, Ubuntu Tricks · Tagged with: , , ,

3 Responses

Subscribe to comments via RSS

  1. Written by humancyborg
    on October 23, 2010 at 6:21 am
    Permalink

    Thanks much for this! Saved me tremendous pain.

  2. Written by John
    on October 29, 2010 at 11:37 am
    Permalink

    THANK YOU

  3. Written by toastkid
    on September 7, 2012 at 9:28 pm
    Permalink

    You’ve got the same bit of code copied twice there, and it has webby quotes. Took me a minute to figure out what was going wrong :)

Subscribe to comments via RSS

Leave a Reply