James Huynh My little tech blog

Save IRB and Rails Console history

This trick is super useful when you want to save the history of the commands that you have typed earlier in IRB or Rails console so that it can re-used back when you need. In order to enable this feature, follow the following steps:

1. Create ~/.irbrc or edit your current ~/.irbrc

vim ~/.irbrc

2. Add in the irb saving history extension require

Add in the following line:

require 'irb/ext/save-history'

3. Optionally, you can configure the number of commands to save

On the same ~/.irbrc file, add in this line:

IRB.conf[:SAVE_HISTORY] = 1000

Notes: The history of your commands would be saved inside ~/.irb_history

Find this article helpful? Consider sharing it!