如何获得“irb(main):001:0>”提示而不是“>>”

时间:2021-03-31 07:11:52

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

Ruby已经预装在我的Mac上了,所以我想看看它。我注意到的第一件事是,irb提示>>而不是irb(主要):001:0>。我找不到任何关于如何通过Google更改此内容的信息,因为每个人都在他们的代码中使用irb(main):001:0> ;-)

Can you help me out?

你能帮我吗?

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

PS:我认为Ruby不是坏了,但我想在编程时看起来更讨厌;-)

3 个解决方案

#1


$ 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> 

#2


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

我所做的是将它变成我的.bashrc中的别名,所以我不必每次都输入它。

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

Hope this helps!

希望这可以帮助!

#3


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

转到位置/home/leapfrog/.rvm/scripts

cd ~/.rvm/scripts

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

打开文件'irbrc.rb',使用超级用户权限覆盖

$ sudo gedit irbrc.rb

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

将哈希“@prompt”的内容更改为以下内容

@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 :)

希望这能帮到你:)

#1


$ 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> 

#2


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

我所做的是将它变成我的.bashrc中的别名,所以我不必每次都输入它。

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

Hope this helps!

希望这可以帮助!

#3


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

转到位置/home/leapfrog/.rvm/scripts

cd ~/.rvm/scripts

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

打开文件'irbrc.rb',使用超级用户权限覆盖

$ sudo gedit irbrc.rb

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

将哈希“@prompt”的内容更改为以下内容

@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 :)

希望这能帮到你:)