Created
July 2, 2009 05:44
-
-
Save jmhodges/139284 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'irb/ext/save-history' | |
module IRB | |
module HistorySavingAbility | |
def HistorySavingAbility.create_finalizer | |
at_exit do | |
if num = IRB.conf[:SAVE_HISTORY] and (num = num.to_i) > 0 | |
if hf = IRB.conf[:HISTORY_FILE] | |
file = File.expand_path(hf) | |
end | |
file = IRB.rc_file("_history") unless file | |
open(file, 'w' ) do |f| | |
hist = HISTORY.to_a | |
f.puts(hist[-num..-1] || hist) | |
end | |
end | |
end | |
end | |
def HistorySavingAbility.extended(obj) | |
HistorySavingAbility.create_finalizer | |
obj.load_history | |
obj | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment