tags:

views:

235

answers:

2

I can change the irb prompt mode with

irb --prompt prompt-mode

I can see what null and simple does, but I can't tell the difference between null and xmp and the difference between default/classic/inf-ruby. Can someone explain to me what these other modes do? It seems pointless to have multiple modes doing the same thing.

A: 

The answer to those questions lie in IRB.conf[:PROMPT] which is a hash whose keys are the different prompts and whose values are the configurations for each prompt. Read this to a understand a prompt's configuration.

The difference between null and xmp is that xmp displays a result indented with an arrow:

$ irb --prompt xmp -f
2**10
    ==>1024

while null doesn't indent or display the arrow:

$ irb --prompt null -f
2**10
1024

You should be able to answer your second question once you read the above link and understand that prompts have different modes and different configurations for them.

A: 

Once you read the article cldwalker posted above, you may want to design a custom 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
Michael Kohl