Skip to content

Instantly share code, notes, and snippets.

@troelskn troelskn/Rakefile
Created Oct 6, 2017

Embed
What would you like to do?
Drop into an IRB session from within a rake task
desc "Start an interactive console"
task :console do
require "irb"
require "irb/completion"
require "pp"
ARGV.clear
IRB.setup(nil)
IRB.conf[:SAVE_HISTORY] = 100
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb_history"
irb = IRB::Irb.new
irb.context.inspect_mode = IRB::Inspector.new(proc{ |v| v.pretty_inspect.chomp })
IRB.conf[:MAIN_CONTEXT] = irb.context
trap "SIGINT" do
irb.signal_handle
end
begin
catch :IRB_EXIT do
irb.eval_input
end
ensure
IRB.irb_at_exit
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.