如何为Git控制台着色? [英] How to color the Git console?
问题描述
我最近看到Windows中的 git
控制台是彩色的,例如绿色表示添加,红色表示删除,等等。如何为 git
控制台着色?
要安装它,我使用了命令: $ sudo apt-get install git-core
注释 > @VonC , color.ui
自Git 1.8.4起默认为 auto
来自Unix& Linux Stackexchange问题如何为git的输出着色?和由@Evgeny回答:
git config --global color.ui auto
color.ui
是元配置,其中包括所有各种color。*
配置git
命令。这在git help config
中有详细解释。
所以基本上比分别设置不同的颜色更容易,而且更适合将来。* 设置。
< a href = http://www.kernel.org/pub/software/scm/git/docs/git-config.html rel = noreferrer> git配置
文档:
color.ui
:此变量确定控制使用情况的变量的默认值,例如color.diff
和color.grep
每个命令系列的颜色。随着更多命令学习配置以设置-color
选项的默认值,其范围将扩大。如果希望所有非供机器使用的输出都使用颜色,请将其设置为始终
,将其设置为true
或自动
,如果您希望此类输出在写入终端时使用颜色,或者false
或从不
,如果您不希望git命令不使用颜色,除非使用其他配置或-color
选项显式启用。
I recently saw that the git
console in Windows is colored, e.g. Green for additions, red for deletions, etc. How do I color my git
console like that?
To install it, I used the command: $ sudo apt-get install git-core
As noted by @VonC, color.ui
defaults to auto
since Git 1.8.4
From the Unix & Linux Stackexchange question How to colorize output of git? and the answer by @Evgeny:
git config --global color.ui auto
The
color.ui
is a meta configuration that includes all the variouscolor.*
configurations available withgit
commands. This is explained in-depth ingit help config
.
So basically it's easier and more future proof than setting the different color.*
settings separately.
In-depth explanation from the git config
documentation:
color.ui
: This variable determines the default value for variables such ascolor.diff
andcolor.grep
that control the use of color per command family. Its scope will expand as more commands learn configuration to set a default for the--color
option. Set it toalways
if you want all output not intended for machine consumption to use color, totrue
orauto
if you want such output to use color when written to the terminal, or tofalse
ornever
if you prefer git commands not to use color unless enabled explicitly with some other configuration or the--color
option.
这篇关于如何为Git控制台着色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!