How to format irb command prompt

前端 未结 7 1179
隐瞒了意图╮
隐瞒了意图╮ 2020-12-09 17:40

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


        
7条回答
  •  隐瞒了意图╮
    2020-12-09 18:27

    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\n"
    }
    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.)

提交回复
热议问题