Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux ZSH中的管道正在从Git日志输出中剥离颜色_Linux_Git_Zsh - Fatal编程技术网

Linux ZSH中的管道正在从Git日志输出中剥离颜色

Linux ZSH中的管道正在从Git日志输出中剥离颜色,linux,git,zsh,Linux,Git,Zsh,我正试图利用GRB的git helpers()来打印我的git日志 第62行的git log--graph--pretty=“tformat:${log\u FORMAT}”命令工作正常;在iTerm中使用颜色打印。但是一旦它被传送到pretty\u git\u格式就不会显示任何颜色 这种方法已经使用了好几年,直到几周前。zsh中是否有需要进行不同配置的更改 我使用的是iTerm2和zsh版本zsh 5.4.2(x86_64-apple-darwin16.7.0)。如果输出打印到终端(直接或通过

我正试图利用GRB的git helpers()来打印我的git日志

第62行的
git log--graph--pretty=“tformat:${log\u FORMAT}”
命令工作正常;在iTerm中使用颜色打印。但是一旦它被传送到
pretty\u git\u格式
就不会显示任何颜色

这种方法已经使用了好几年,直到几周前。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\u FORMAT}”
(是的,这就是
-c
选项的位置)。如果您想经常这样做,可以使用
.gitconfig
中的shell别名来完成


虽然您也可以在
.gitconfig
中设置,但您可能不想这样做。大多数外部程序都假定颜色已关闭,如果您在
中设置此选项,您可以破坏git的其他部分以及编辑器集成等工具。gitconfig

在更新到OSX High Sierra并更新我的自制软件包后,我今天开始遇到这种情况

我怀疑这与最新的Git版本(2.15.0)有关,因为这些版本提到更改Git日志的颜色工作方式:

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\u git\u format
的列格式。

您是否检查了寻呼机是否保留了原始输出(以保留颜色)
git config--global core.pager'less-R'
:不是这样。即使我只是
git log--graph--pretty=“tformat:${log\u FORMAT}”| cat
它也不带颜色打印。谢谢。这很有效。但我想知道为什么现在需要这样做,而在过去它不是。@MatthewBoston-我也有同样的问题。添加
-c color.ui=always
就像您所说的那样,但似乎也会影响
pretty\u git\u format
中的列格式。你也发现了吗?