How to format irb command prompt

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


When you would usually run the irb command, try running irb --simple-prompt instead. That greatly shortens the prompt and makes it easier to understand.


In your ~/.irbrc, simply add

IRB.conf[:PROMPT_MODE] = :SIMPLE

Tags:

Ruby

Irb