![](/img/trans.png)
[英]How do I stop supervisord from stripping colors from the log output of my Node.js server?
[英]Pipe in ZSH is stripping colors from Git log output
我正在尝试利用GRB的git助手( https://github.com/garybernhardt/dotfiles/blob/master/.githelpers )来打印我的git日志。
第62行的git log --graph --pretty="tformat:${LOG_FORMAT}"
命令工作得很好; 在iTerm中使用颜色打印。 但是一旦它pretty_git_format
送到pretty_git_format
,就没有显示颜色。
这已经持续了几年,直到几周前。 我现在需要配置不同的zsh有变化吗?
我正在使用iTerm2和zsh版本zsh 5.4.2(x86_64-apple-darwin16.7.0)。
git的默认行为是在输出被打印到终端(直接或通过git生成的寻呼机)时产生颜色。 当你的输出到达其他地方时,就像管道一样,git会关闭颜色。
您可以将color.ui
选项设置为always
在命令行上,如下所示: git -c color.ui=always log --graph --pretty="tformat:${LOG_FORMAT}"
(是的,这就是-c
选项去)。 如果您想经常这样做,可以使用.gitconfig
的shell别名来.gitconfig
。
虽然您也可以在.gitconfig
设置它,但您可能不希望这样。 大多数外部程序都假设颜色已关闭,如果你在.gitconfig
设置它,你可以打破git的其他部分,以及编辑器集成等工具。
在更新到OSX High Sierra并更新我的自制程序包之后,今天就开始发生这种情况了。
我怀疑它与最新的Git版本(2.15.0)有关,因为这些发行说明提到了改变git log
颜色的工作方式:
Fixes since v2.14
-----------------
* "%C(color name)" in the pretty print format always produced ANSI
color escape codes, which was an early design mistake. They now
honor the configuration (e.g. "color.ui = never") and also tty-ness
of the output medium.
所以我认为Brian的解决方案可能是最好的解决方案,但我注意到它确实会影响pretty_git_format
的列格式,我在上面的评论中提到过。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.