You have a lot of flexibility in configuring the prompts that irb
uses. Sets of prompts are stored in the prompt hash:
For example, to establish a new prompt mode called ``MY_PROMPT'', you
might enter the following (either directly at an irb prompt or in the
.irbrc
file):
IRB.conf[:PROMPT][:MY_PROMPT] = { # name of prompt mode
:PROMPT_I => "...", # normal prompt
:PROMPT_S => "...", # prompt for continuing strings
:PROMPT_C => "...", # prompt for continuing statement
:RETURN => " ==>%s\n" # format to return value
}
|
Then, invoke irb with the prompt mode above by
% irb --prompt my-prompt
Or set the following configuration value:
IRB.conf[:PROMPT_MODE] = :MY_PROMPT
|
The constants
PROMPT_I
,
PROMPT_S
, and
PROMPT_C
specify the format for each of the prompt strings. Within the prompt
format, the following flags are available and will expand to the
given text:
Flag
|
Description
|
%N
|
Current command. |
%m
|
to_s of the main object (self). |
%M
|
inspect of the main object (self). |
%l
|
Delimiter type. In strings that are continued across a line break,
%l will display the type of delimiter used to begin the
string, so you'll know how to end it. The delimiter will be
one of " , ' , / , ] , or ` . |
%ni
|
Indent level. The optional number n is used as a width
specification to printf, as printf("%nd") . |
%nn
|
Current line number (n used as with the indent level). |
%%
|
A literal percent sign. |
|
For instance, the default prompt mode is defined as follows:
IRB.conf[:PROMPT_MODE][:DEFAULT] = {
:PROMPT_I => "%N(%m):%03n:%i> ",
:PROMPT_S => "%N(%m):%03n:%i%l ",
:PROMPT_C => "%N(%m):%03n:%i* ",
:RETURN => "%s\n"
}
|