I want to change the prompt of Scala REPL. I found out that I can change the prompt in power-mode like the following.
scala>
scala> :power
** Power User mode enabled - BEEP WHIR GYVE **
** :phase has been set to 'typer'. **
** scala.tools.nsc._ has been imported **
** global._, definitions._ also imported **
** Try :help, :vals, power.<tab> **
scala> repl.setPrompt("\ncool prompt!> ")
cool prompt!>
Now I want to do this in normal mode or initialCommands
of sbt console. Does anyone know how to do this?
We can start Scala REPL by typing scala command in console/terminal.
The Scala REPL (“Read-Evaluate-Print-Loop”) is a command-line interpreter that you use as a “playground” area to test your Scala code.
The scala command will execute a source script by wrapping it in a template and then compiling and executing the resulting program. In interactive mode, the REPL reads expressions at the prompt, wraps them in an executable template, and then compiles and executes the result.
Scala REPL is a command-line tool for the expression, evaluation, and execution of small code snippets. The acronym REPL stands for “Read-Evaluate-Print-Loop”. Similar to Java Shell, Scala REPL is very useful to newcomers and to those who want to experiment with new libraries or language features.
Scala 2.10.0
$intp.asInstanceOf[scala.tools.nsc.interpreter.ILoop$ILoopInterpreter]
.getClass
.getDeclaredField("$outer").get($intp)
.asInstanceOf[scala.tools.nsc.interpreter.ILoop]
.setPrompt("\ncool prompt!> ")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With