Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
527 views
in Technique[技术] by (71.8m points)

ruby - How to format irb command prompt

Previously I was using Ruby 1.8 and my irb command prompt used to look like this:

Air ~: irb
>> a = 1
=> 1
>> b = 2
=> 2
>> a + b
=> 3

I installed rvm (and Ruby 1.9.2) and now my irb command prompt looks like this:

Air ~: irb
ruby-1.9.2-p180 :001 > a = 1
 => 1 
ruby-1.9.2-p180 :002 > b = 2
 => 2 
ruby-1.9.2-p180 :003 > a + b
 => 3 

Is there a way to remove the ruby-1.9.2-p180 :001 from the command line?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The irb man page has a section on "Customizing prompt". Here's mine for example:

IRB.conf[:PROMPT][:CUSTOM] = {
  :PROMPT_I => ">> ",
  :PROMPT_S => "%l>> ",
  :PROMPT_C => ".. ",
  :PROMPT_N => ".. ",
  :RETURN => "=> %s
"
}
IRB.conf[:PROMPT_MODE] = :CUSTOM
IRB.conf[:AUTO_INDENT] = true

To use this, add it to your ~/.irbrc file (creating it if it doesn't exist.)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...