1

I have tried :

@CONF[:PROMPT_MODE] = :SIMPLE

but it does not change my prompt. I am using rvm and ruby 1.9.2 Linux.

#!/usr/bin/env ruby
# encoding: utf-8
require 'irb'
module IRB # :nodoc:
    def self.start_session(binding)
    unless @__initialized
        args = ARGV
        ARGV.replace(ARGV.dup)
        IRB.setup(nil)
        ARGV.replace(args)
        @__initialized = true
    end
    workspace = WorkSpace.new(binding)
    irb = Irb.new(workspace)
    @CONF[:IRB_RC].call(irb.context) if @CONF[:IRB_RC]
    @CONF[:MAIN_CONTEXT] = irb.context
    @CONF[:AUTO_INDENT] = true
    @CONF[:PROMPT_MODE] = :SIMPLE
    catch(:IRB_EXIT) do
        irb.eval_input
    end
end
end
IRB.start_session(binding)
tshepang
  • 12,111
  • 21
  • 91
  • 136

1 Answers1

0

The configuration assignment:

@CONF[:PROMPT_MODE] = :SIMPLE

needs to come before creating the Irb object:

irb = Irb.new(workspace)

I am not sure how early the other settings have to be done, but in general it's better to do this as soon as possible. The code below has these modifications.

#!/usr/bin/env rub
# encoding: utf-8
require 'irb'
module IRB # :nodoc:
    def self.start_session(binding)
        unless @__initialized
            args = ARGV
            ARGV.replace(ARGV.dup)
            IRB.setup(nil)
            ARGV.replace(args)
            @__initialized = true
        end
        @CONF[:IRB_RC].call(irb.context) if @CONF[:IRB_RC]
        @CONF[:AUTO_INDENT] = true
        @CONF[:PROMPT_MODE] = :SIMPLE
        IRB.run_config
        workspace = WorkSpace.new(binding)
        irb = Irb.new(workspace)
        @CONF[:MAIN_CONTEXT] = irb.context
        catch(:IRB_EXIT) do
            irb.eval_input
        end
    end
end
IRB.start_session(binding)

Sorry, I didn't see this sooner.

rocky
  • 7,226
  • 3
  • 33
  • 74