Is it possible to change the prompt of Scala REPL programatically?
read-eval-print-loop, scala
Solution
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!> ")
Problem
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?