> " Ruby was pre-installed on my Mac, so I wanted to look at it. The first thing I noticed is...">

How to get hint irb (main): 001: 0> "instead of" >> "

Ruby was pre-installed on my Mac, so I wanted to look at it. The first thing I noticed is that irb prompts → instead of irb (main): 001: 0>. I can’t find anything about how to change this using Google, because everyone uses irb (main): 001: 0> in their code; -)

You can help me?

PS: This is not what I think Ruby is broken, but I want to look more stubborn during programming; -)

+3
source share
3 answers
$ 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> 
+10
source

I do this in an alias in my .bashrc, so I don't need to enter it every time.

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

Hope this helps!

0

/home/leapfrog/.rvm/scripts

cd ~/.rvm/scripts

Open the file "irbrc.rb", use superuser privileges to overwrite

$ sudo gedit irbrc.rb

Change the contents of the @prompt hash 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 helps you :)

0
source

Source: https://habr.com/ru/post/1702808/


All Articles