如何使用环境变量禁用 git 颜色?

How to disable git colors using an environment variable?

有没有办法使用环境变量禁用 git 颜色?

背景

通常当我 运行 git 时,我希望输出着色。因此,我的 .gitconfig 有:

[color]
        ui = auto

然而,当在 gVim 终端中 运行ning git 时,颜色并不难读。我只想在从 gVim 终端 运行ning 时禁用颜色,如果存在,我可以通过设置环境变量来实现。

GIT_CONFIG_PARAMETERS="'color.ui=never'"

虽然我没有找到这方面的文档,但它包含在 git test case here:

test_expect_success 'GIT_CONFIG_PARAMETERS handles old-style entries' '
    v="${SQ}key.one=foo${SQ}" &&
    v="$v  ${SQ}key.two=bar${SQ}" &&
    v="$v ${SQ}key.ambiguous=section.whatever=value${SQ}" &&
    GIT_CONFIG_PARAMETERS=$v git config --get-regexp "key.*" >actual &&
    cat >expect <<-EOF &&
    key.one foo
    key.two bar
    key.ambiguous section.whatever=value
    EOF
    test_cmp expect actual

您可以简单地使用 g:terminal_ansi_colors 变量更改 GVim 的终端颜色,其值预计是 16 种十六进制颜色的列表,对应于 16 种所谓的“ANSI 颜色”:

let g:terminal_ansi_colors = [
    \ '#1c1c1c',
    \ '#af5f5f',
    \ '#5f875f',
    \ '#87875f',
    \ '#5f87af',
    \ '#5f5f87',
    \ '#5f8787',
    \ '#6c6c6c',
    \ '#444444',
    \ '#ff8700',
    \ '#87af87',
    \ '#ffffaf',
    \ '#8fafd7',
    \ '#8787af',
    \ '#5fafaf',
    \ '#ffffff',
    \ ]

以上数值取自我的配色方案;随意使用适合您的任何东西。