Skip to content
This repository
tree: e3d7f1d4ef
Fetching contributors…

Cannot retrieve contributors at this time

file 24 lines (21 sloc) 0.507 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
IRB.conf[:USE_READLINE] = true

module Readline
  module History
    LOG = "#{ENV["HOME"]}/.irb-save-history"
    def self.write_log(line)
      File.open(LOG, 'ab') {|f| f << "#{line}\n"} unless line == "exit"
    end
  end

  alias :old_readline :readline
  def readline(*args)
    ln = old_readline(*args)
    begin
      History.write_log(ln)
    rescue
    end
    ln
  end
end

require 'irb/ext/save-history'
IRB.conf[:SAVE_HISTORY] = 1000
IRB.conf[:HISTORY_FILE] = "#{ENV["HOME"]}/.irb-save-history"
Something went wrong with that request. Please try again.