简体   繁体   English

我可以调整 git 中默认 colors 的值吗?

[英]Can I tweak the values of the default colors in git?

I know that git supports some "basic" named colors: normal, black, red, green, yellow, blue, magenta, cyan and white (see eg this SO question ).我知道 git 支持一些名为 colors 的“基本”:正常,黑色,红色,绿色,黄色,蓝色,洋红色,青色和白色(参见例如这个 SO question )。

My question: can I change the actual values of these named colors, eg make the blue brighter?我的问题:我可以更改这些名为 colors 的实际值,例如使蓝色更亮吗? Note I don't mean change the colors of every single git command, just the default interpretation of colors.请注意,我并不是说更改每个 git 命令的 colors,只是 colors 的默认解释。

More specifically, if I could get them to match my LS_COLORS, that would be neat.更具体地说,如果我能让它们与我的 LS_COLORS 匹配,那就太好了。

Git colors can be expressed in hex as explained here . Git colors 可以用十六进制表示,如此所述。

Git's color values are for talking to a terminal emulator, the words map to standard color requests. Git 的颜色值用于与终端仿真器对话,字词 map 用于标准颜色请求。

Git translates the color values you give to your terminal's standard request for them. Git 将您提供的颜色值转换为终端对其的标准要求。 You say you want green , git translates that to the terminal's request for slot 2, and the terminal displays whatever you've configured it to display for that.您说您想要green , git 将其转换为终端对插槽 2 的请求,并且终端会显示您为其配置的任何内容。

There's no additional layer of indirection, you say what colors and attributes you want.没有额外的间接层,你说你想要什么 colors 和属性。 You can specify which specific colors get used in various circumstances, eg for whitespace errors or very old changes in blame output or whatever, see the docs, but if you want to build some abstraction layer between what you say and what you mean you get to build that yourself and make it ask Git for what you mean instead of just asking Git yourself.您可以指定在各种情况下使用哪些特定的 colors,例如对于空白错误或责备 output 或其他任何内容的非常旧的更改,请参阅文档,但如果您想在您所说的和您的意思之间构建一些抽象层自己构建它并让它询问 Git 你的意思,而不是自己问 Git。

Git allows you to specify colours as one of three ways: a name, a 256-bit colour value, or a hex value. Git 允许您将颜色指定为以下三种方式之一:名称、256 位颜色值或十六进制值。 If you use the name, or you use one of the first 16 colours of the 256 colour values (0-15), then you're asking for the terminal default colour of that type.如果您使用名称,或者您使用 256 个颜色值 (0-15) 的前 16 种颜色之一,那么您要求的是该类型的终端默认颜色。 That will be set to whatever your terminal happens to be set to, and as you can see on Wikipedia , the defaults for various terminals differ greatly.这将设置为您的终端碰巧设置的任何内容,正如您在 Wikipedia 上看到的那样,各种终端的默认设置差异很大。

If your terminal supports 256 colours (which most terminal emulators do these days), then you can use the other 240 colour numbers and you'll generally get a repeatable colour, since those values are typically fixed.如果您的终端支持 256 种颜色(现在大多数终端模拟器都支持),那么您可以使用其他 240 种颜色编号,并且通常会获得可重复的颜色,因为这些值通常是固定的。 Similarly, if your terminal supports true colour (not all do), then you can use a hex value as well, which will of course be fixed.同样,如果您的终端支持真彩色(并非全部支持),那么您也可以使用十六进制值,这当然是固定的。

If you have certain values in your LS_COLORS , you can run dircolors -p to see an explanation of what the default values mean;如果您的LS_COLORS中有某些值,您可以运行dircolors -p查看默认值含义的解释; most of the attributes there correspond to various options you can specify and that are documented in git config --help .那里的大多数属性对应于您可以指定的各种选项,并且记录在git config --help中。 You may find that if you're looking for the brighter variant of the colour, that brightblue may be what you're looking for.您可能会发现,如果您正在寻找更亮的颜色变体,那么明亮的brightblue可能就是您正在寻找的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM