How can colored terminal output be disabled for sbt/play?

ScalaPlayframeworkSbt

Scala Problem Overview


I would like to disable the color escape codes logged from sbt/play. Is this possible? And if it is, is there a way to do it without making changes to the config - i.e. via a command line switch or system property.

Scala Solutions


Solution 1 - Scala

Since version 0.13.8 (and possibly earlier) you can now simply use the -no-colors option to sbt. e.g.

sbt -no-colors test

Solution 2 - Scala

You can simply set the system property sbt.log.noformat to true. If you want to e.g. use SBT inside Vim you can create a script like this:

#!/bin/bash
java -Dsbt.log.noformat=true $JAVA_OPTS -jar "${HOME}/bin/sbt-launch.jar" "$@"

Solution 3 - Scala

This sounds like your platform does not match the actual jline.terminal property. I am just guessing here but when I pass the parameter as Daniel suggested on a Windows command line I see the color escape codes as well.

Therefore, you have to make sure the property matches your platform, i.e. WindowsTerminal on Windows and UnixTerminal on Unix.

If this does not help, then you might be on an unsupported platform in which case the website suggests to use:

-Djline.terminal=jline.UnsupportedTerminal

Solution 4 - Scala

Well, you can get colors on Windows by installing Cygwin and passing this parameter:

-Djline.terminal=jline.UnixTerminal

So I'd look up jline parameters to see what disables color coding.

Solution 5 - Scala

I was able to get colored output from SBT in Cygwin by adding:

-Djline.terminal=jline.UnixTerminal

Additionally I figured out that I also needed to add the following line to Cygwin.bat:

set CYGWIN=tty ntsec

After that is added SBT gives very nice colored output. Additionally I would recommend looking into Console2 as it can hook through Cygwin, but provides a much better interface in my opinion:

http://sourceforge.net/projects/console/

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMark HibberdView Question on Stackoverflow
Solution 1 - ScalaSteven ShawView Answer on Stackoverflow
Solution 2 - ScalaMoritzView Answer on Stackoverflow
Solution 3 - ScalawebersteView Answer on Stackoverflow
Solution 4 - ScalaDaniel C. SobralView Answer on Stackoverflow
Solution 5 - ScaladarkfrogView Answer on Stackoverflow