如何为 Git 控制台着色? [英] How to color the Git console?

查看:24
本文介绍了如何为 Git 控制台着色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近看到 Windows 中的 git 控制台是彩色的,例如绿色表示添加,红色表示删除等.如何为 git 控制台着色?

为了安装它,我使用了命令:$ sudo apt-get install git-core

解决方案

As 注意到 by @VonCcolor.ui 默认为 auto 自 Git 1.8.4

<小时>

来自 Unix &Linux Stackexchange 问题 如何为 git 的输出着色?@Evgeny 的回答:

git config --global color.ui auto

<块引用>

color.ui 是一个元配置,包括所有各种 color.* 配置,可用于 git 命令.这在 git help config 中有深入的解释.

所以基本上它比单独设置不同的 color.* 设置更容易且更具前瞻性.

深入解释来自git配置文档:

<块引用>

color.ui:这个变量决定了color.diffcolor.grep等变量的默认值code> 控制每个命令系列的颜色使用.随着更多命令学习配置以设置 --color 选项的默认值,其范围将扩大.如果您希望所有不供机器使用的输出都使用颜色,请将其设置为 always,如果您希望使用此类输出,则将其设置为 trueauto写入终端时的颜色,或者 falsenever 如果您不希望 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 various color.* configurations available with git commands. This is explained in-depth in git 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 as color.diff and color.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 to always if you want all output not intended for machine consumption to use color, to true or auto if you want such output to use color when written to the terminal, or to false or never if you prefer git commands not to use color unless enabled explicitly with some other configuration or the --color option.

这篇关于如何为 Git 控制台着色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆