Persisting IRB & Rails Console History

Continuing the theme on customising IRB and Rails Console, add these lines to ~/.irbrc to persist the command history across console sessions:

require 'irb/ext/save-history'
IRB.conf[:SAVE_HISTORY] = 100
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb_history"

Awesome Print your IRB & Rails Console

Awesome Print is a Ruby gem that prints prettified objects to the console. To avoid having to prepend ap to all your console commands, set it as the default formatter in IRB and Rails by adding the following to your ~/.irbrc:

require 'awesome_print'
IRB::Irb.class_eval do
  def output_value
    ap @context.last_value
  end
end

Obviously, Awesome Print first needs to be installed: gem install awesome_print

UPDATE: Awesome Print now includes a method to make the integration process easier.

require 'awesome_print'
AwesomePrint.irb!