Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to have colored REPL for 'sbt console'?

Tags:

scala

sbt

From Scala 2.11.4 onwards you can get a colored REPL by invoking scala -Dscala.color. My question is whether it is possible to get the same colored REPL when I call sbt console within my SBT project?

like image 782
marios Avatar asked Nov 20 '15 16:11

marios


4 Answers

starting from scala 2.12.2, the repl is colored by default; so you just need to set the scalaVersion property in ~/.sbt/user.sbt file:

scalaVersion := "2.12.2"
like image 145
7kemZmani Avatar answered Nov 10 '22 23:11

7kemZmani


In the same way:

sbt -Dscala.color console

This also works if you just invoke sbt -Dscala.color and then later jump into console.

like image 36
knutwalker Avatar answered Nov 11 '22 00:11

knutwalker


Put this into your ~/.sbt/0.13/user.sbt:

initialize ~= { _ =>
  val ansi = System.getProperty("sbt.log.noformat", "false") != "true"
  if (ansi) System.setProperty("scala.color", "true")
}
like image 13
Twistleton Avatar answered Nov 11 '22 00:11

Twistleton


Create a ~/.sbt/0.13/colour.sbt with:

initialize ~= (_ => if (ConsoleLogger.formatEnabled) sys.props("scala.color") = "true")
like image 1
Dale Wijnand Avatar answered Nov 10 '22 23:11

Dale Wijnand