Skip to content

Instantly share code, notes, and snippets.

@derekharmel
Created August 15, 2013 09:45
Show Gist options
  • Save derekharmel/6239651 to your computer and use it in GitHub Desktop.
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
#!/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