Guest User

Untitled

a guest
Apr 20th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. require 'irb/completion'
  2. ARGV.concat [ "--readline", "--prompt-mode", "simple" ]
  3.  
  4. module Readline
  5. module History
  6. LOG = "#{ENV['HOME']}/.irb-history"
  7.  
  8. def self.write_log(line)
  9. File.open(LOG, 'ab') {|f| f << "#{line}
  10. "}
  11. end
  12.  
  13. def self.start_session_log
  14. write_log("
  15. # session start: #{Time.now}
  16.  
  17. ")
  18. at_exit { write_log("
  19. # session stop: #{Time.now}
  20. ") }
  21. end
  22. end
  23.  
  24. alias :old_readline :readline
  25. def readline(*args)
  26. ln = old_readline(*args)
  27. begin
  28. History.write_log(ln)
  29. rescue
  30. end
  31. ln
  32. end
  33. end
  34.  
  35. Readline::History.start_session_log
  36.  
  37.  
  38. require 'irb/ext/save-history'
  39. IRB.conf[:SAVE_HISTORY] = 100
  40. IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-save-history"
Add Comment
Please, Sign In to add comment