How do I get the "irb(main):001:0>" prompt instead of ">>"
Asked Answered
D

3

5

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 ;-)

Dulcine answered 6/2, 2009 at 12:22 Comment(1)
also see: tip ruby irb auto complete <br> how to enable auto compleation in rubys irbAargau
F
13
$ 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> 
Fourway answered 6/2, 2009 at 12:30 Comment(0)
C
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!

Cornemuse answered 16/6, 2013 at 0:45 Comment(0)
N
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 :)

Nursling answered 24/12, 2014 at 3:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.