LoginSignup
20

More than 5 years have passed since last update.

irbの履歴を保存する

Posted at

irbはちょっと試してみる分には便利なんですが、
いつも何を入力したか忘れてしまうので、
まとめてスクリプトに保存しようとするとちょっと面倒です。

そこで、~/.irbrcに以下のように書くと、
~/.irb_historyに履歴が残るようになります。

そこから必要なところを抜き出してあげることで、
簡単にスクリプトを作ることができます。

require 'irb/completion'
require 'irb/ext/save-history'

IRB.conf[:SAVE_HISTORY] = 10000
IRB.conf[:HISTORY_FILE] = File.expand_path('~/.irb_history') 

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
20