0

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 2

1

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 + '> ' }
2
  • Thanks. It worked. Can you also tell me the commands for changing the prompt | in the continuation and the prompt => in the result?
    – sawa
    May 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 and gem man ripl.
    – cldwalker
    May 23, 2011 at 23:51
0

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

2
  • I have ripl/irb required, and when I do IRB.conf[:PROMPT][:DEFAULT] = ..., which works in irb, it returns an error saying that Object::IRB is not defined.
    – sawa
    May 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.
    – cldwalker
    May 23, 2011 at 13:14

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.