I am trying to configure the prompt characters in ripl, an alternative to interactive ruby (irb). In irb, it is done using IRB.conf[:DEFAULT]
, but it does not seem to work with ripl. I am also having difficulty finding an instruction for it. Please guide to a link for an explanation or give a brief explanation.
2 Answers
Configuring a dynamic prompt in ~/.riplrc:
# Shows current directory
Ripl.config[:prompt] = lambda { Dir.pwd + '> ' }
# Print current line number
Ripl.config[:prompt] = lambda { "ripl(#{Ripl.shell.line})> " }
# Simple string prommpt
Ripl.config[:prompt] = '>>> '
Changing the prompt in the shell:
>> Ripl.shell.prompt = lambda { Dir.pwd + '> ' }
-
Thanks. It worked. Can you also tell me the commands for changing the prompt
|
in the continuation and the prompt=>
in the result?– sawaMay 23, 2011 at 19:52 -
Those configurations respectively are Ripl.config[:multi_line_prompt] and Ripl.config[:result_prompt]. The first can be dynamic or a string and the second one can only be a string. For more docs:
gem install gem-man
andgem man ripl
. May 23, 2011 at 23:51
ripl loads your ~/.irbrc file, which typically contains some irb specific options (e.g. IRB.conf[:PROMPT]). To avoid errors, you can install ripl-irb, which catches calls to the IRB constant and prints messages to convert irb configuration to ripl equivalents.
http://rbjl.net/44-ripl-why-should-you-use-an-irb-alternative
-
I have
ripl/irb
required, and when I doIRB.conf[:PROMPT][:DEFAULT] = ...
, which works in irb, it returns an error saying thatObject::IRB
is not defined.– sawaMay 23, 2011 at 7:18 -
You need to require ripl/irb at the beginning of ripl i.e.
ripl -rripl/irb
or put it in your ~/.riplrc for it to work correctly. May 23, 2011 at 13:14