Created
May 12, 2013 19:16
-
-
Save aarondufall/5564581 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 'rubygems' | |
require 'awesome_print' | |
require 'irb/completion' | |
ARGV.concat [ "--readline", "--prompt-mode", "simple" ] | |
module Readline | |
module History | |
LOG = "#{ENV['HOME']}/.irb-history" | |
def self.write_log(line) | |
File.open(LOG, 'ab') {|f| f << "#{line}\n"} | |
end | |
def self.start_session_log | |
write_log("\n# session start: #{Time.now}\n\n") | |
at_exit { write_log("\n# session stop: #{Time.now}\n") } | |
end | |
end | |
alias :old_readline :readline | |
def readline(*args) | |
ln = old_readline(*args) | |
begin | |
History.write_log(ln) | |
rescue | |
end | |
ln | |
end | |
end | |
IRB::Irb.class_eval do | |
def output_value | |
ap @context.last_value | |
end | |
end | |
Readline::History.start_session_log | |
require 'irb/ext/save-history' | |
IRB.conf[:SAVE_HISTORY] = 100 | |
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-save-history" | |
IRB.conf[:PROMPT_MODE] = :SIMPLE | |
require 'irb/completion' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment