4

Ruby is preinstalled on my Mac and so I wanted to have a look at it. First thing I noticed, is that irb prompts >> instead of irb(main):001:0>. I can't find anything on how to change this with Google because everyone is using irb(main):001:0> in their code ;-)

Can you help me out?

PS: It's not that I think Ruby is broken, but I want to look more nerdy while programming ;-)

Christian
  • 1,027
  • 1
  • 13
  • 26
  • also see: [tip ruby irb auto complete](http://www.sufixo.com/raw/2006/05/29/tip_ruby_irb_auto-complete/)
    [how to enable auto compleation in rubys irb](http://stackoverflow.com/questions/1382063/how-to-enable-auto-compleation-in-rubys-irb)
    – dwright Oct 21 '09 at 18:27

3 Answers3

11
$ irb --help
Usage:  irb.rb [options] [programfile] [arguments]
  --prompt prompt-mode
  --prompt-mode prompt-mode
            Switch prompt mode. Pre-defined prompt modes are
            `default', `simple', `xmp' and `inf-ruby'

$ irb --prompt inf-ruby
irb(main):001:0> 
Community
  • 1
  • 1
troelskn
  • 115,121
  • 27
  • 131
  • 155
0

What I do is make that into an alias in my .bashrc so I don't have to type it every time.

echo alias irb=\'irb --prompt inf-ruby\' >> ~/.bashrc

Hope this helps!

evanthegrayt
  • 71
  • 2
  • 6
0

goto the location /home/leapfrog/.rvm/scripts

cd ~/.rvm/scripts

Open the file ‘irbrc.rb’, use superuser power to over-write the

$ sudo gedit irbrc.rb

Change the content of the hash '@prompt' to the following

@prompt = {
 :PROMPT_I => "#{rvm_ruby_string} :%03n > ", # default prompt
 :PROMPT_S => "#{rvm_ruby_string} :%03n%l> ", # known continuation
 :PROMPT_C => "#{rvm_ruby_string} :%03n > ",
 :PROMPT_N => "#{rvm_ruby_string} :%03n?> ", # unknown continuation
 :RETURN => " => %s \n",
 :AUTO_INDENT => true
}

Hope this help you :)

Shiva
  • 11,485
  • 2
  • 67
  • 84