sawa
sawa

Reputation: 168239

How to change the prompt

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.

Upvotes: 0

Views: 614

Answers (2)

cldwalker
cldwalker

Reputation: 6175

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 + '> ' }

Upvotes: 1

Michael Kohl
Michael Kohl

Reputation: 66867

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

Upvotes: 0

Related Questions