Created
August 15, 2013 09:45
-
-
Save derekharmel/6239651 to your computer and use it in GitHub Desktop.
Create an irb session that can access local variables from the startup script
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
#!/usr/bin/env ruby | |
require 'irb' | |
foo = 'bar' | |
IRB.setup(nil) | |
irb = IRB::Irb.new(nil) | |
IRB.conf[:MAIN_CONTEXT] = irb.context | |
irb.context.workspace = IRB::WorkSpace.new(binding) | |
trap 'INT' do | |
irb.signal_handle | |
end | |
catch(:IRB_EXIT) { irb.eval_input } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment