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

后端 未结 5 1244
误落风尘
误落风尘 2020-12-13 17:30

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

相关标签:
5条回答
  • 2020-12-13 17:31

    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" "$@"
    
    0 讨论(0)
  • 2020-12-13 17:32

    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
    
    0 讨论(0)
  • 2020-12-13 17:40

    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
    
    0 讨论(0)
  • 2020-12-13 17:42

    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.

    0 讨论(0)
  • 2020-12-13 17:52

    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/

    0 讨论(0)
提交回复
热议问题