William said:
Joel,
Thanks for that. Unfortunately it doesn't work for me.
I get lots of errors like the following
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/e2mmap.rb:152:
warning: already initialized constant UnrecognizedSwitch
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/e2mmap.rb:152:
warning: already initialized constant NotImplementedError
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/e2mmap.rb:152:
warning: already initialized constant CantReturnToNormalMode
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/e2mmap.rb:152:
warning: already initialized constant IllegalParameter
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/e2mmap.rb:152:
warning: already initialized constant IrbAlreadyDead
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/e2mmap.rb:152:
warning: already initialized constant IrbSwitchedToCurrentThread
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/e2mmap.rb:152:
warning: already initialized constant NoSuchJob
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/e2mmap.rb:152:
warning: already initialized constant CantShiftToMultiIrbMode
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/e2mmap.rb:152:
warning: already initialized constant CantChangeBinding
However, I googled "IRB.start_session" and found some other interesting
post and replies (all by you I think!); and I can see other things are
possible.
I'm going to look at this again tomorrow.
Thanks
William
Sorry, cut-and-paste error
Removing the
IRB.setup nil
call should help. Here's the code for .irbrc:
module IRB
def IRB.start_session(*args)
workspace = WorkSpace.new(*args)
if @CONF[:SCRIPT] ## normally, set by parse_opts
$irb = Irb.new(workspace, @CONF[:SCRIPT])
else
$irb = Irb.new(workspace)
end
@CONF[:IRB_RC].call($irb.context) if @CONF[:IRB_RC]
@CONF[:MAIN_CONTEXT] = $irb.context
trap 'INT' do
$irb.signal_handle
end
custom_configuration if defined?(IRB.custom_configuration)
catch :IRB_EXIT do
$irb.eval_input
end
end
end
x = Object.new
puts "\nStarted irb shell for x"
IRB.start_session(x)