![](/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.