scala 如何为 sbt/play 禁用彩色终端输出?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4267014/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can colored terminal output be disabled for sbt/play?
提问by Mark Hibberd
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.
我想禁用从 sbt/play 记录的颜色转义码。这可能吗?如果是,有没有办法在不更改配置的情况下做到这一点 - 即通过命令行开关或系统属性。
采纳答案by Moritz
You can simply set the system property sbt.log.noformatto true. If you want to e.g. use SBT inside Vim you can create a script like this:
您可以简单地将系统属性设置sbt.log.noformat为true. 例如,如果你想在 Vim 中使用 SBT,你可以创建一个这样的脚本:
#!/bin/bash
java -Dsbt.log.noformat=true $JAVA_OPTS -jar "${HOME}/bin/sbt-launch.jar" "$@"
回答by Steven Shaw
Since version 0.13.8(and possibly earlier) you can now simply use the -no-colorsoption to sbt. e.g.
从版本0.13.8(可能更早)开始,您现在可以简单地使用-no-colorssbt 选项。例如
sbt -no-colors test
回答by weberste
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.
这听起来像您的平台与实际的 jline.terminal 属性不匹配。我只是在这里猜测,但是当我按照 Daniel 在 Windows 命令行上的建议传递参数时,我也看到了颜色转义码。
Therefore, you have to make sure the property matches your platform, i.e. WindowsTerminal on Windows and UnixTerminal on Unix.
因此,您必须确保该属性与您的平台匹配,即 Windows 上的 WindowsTerminal 和 Unix 上的 UnixTerminal。
If this does not help, then you might be on an unsupported platform in which case the websitesuggests to use:
如果这没有帮助,那么您可能在不受支持的平台上,在这种情况下,网站建议使用:
-Djline.terminal=jline.UnsupportedTerminal
回答by darkfrog
I was able to get colored output from SBT in Cygwin by adding:
通过添加,我能够从 Cygwin 中的 SBT 获得彩色输出:
-Djline.terminal=jline.UnixTerminal
Additionally I figured out that I also needed to add the following line to Cygwin.bat:
此外,我发现我还需要将以下行添加到 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:
之后添加 SBT 会提供非常漂亮的彩色输出。此外,我建议查看 Console2,因为它可以连接 Cygwin,但在我看来提供了更好的界面:
回答by Daniel C. Sobral
Well, you can getcolors on Windows by installing Cygwin and passing this parameter:
好吧,您可以通过安装 Cygwin 并传递此参数在 Windows 上获取颜色:
-Djline.terminal=jline.UnixTerminal
So I'd look up jline parameters to see what disables color coding.
所以我会查找 jline 参数,看看是什么禁用了颜色编码。

