What is the difference between ruby ​​irb prompt modes?

I can change the irb prompt mode with

irb --prompt prompt-mode 

I see what null and simple , but I cannot 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 several modes doing the same thing.

+4
source share
2 answers

The answer to these questions lies in IRB.conf [: PROMPT], which is a hash whose keys are different hints and whose values ​​are the configurations for each hint. Read this to understand the invitation configuration .

The difference between zero and xmp is that xmp displays the indented result with an arrow:

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

while null does not indent or display an arrow:

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

You should be able to answer your second question after reading the link above and realizing that the invitations have different modes and different configurations for them.

+4
source

After you read the cldwalker article published above, you may need to create 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 
+7
source

Source: https://habr.com/ru/post/1304420/


All Articles