有没有办法使用环境变量禁用 git 颜色?
背景
通常当我运行 git 时,我希望输出是彩色的。因此,我的 .gitconfig 有:
[color]
ui = auto
但是,当从 gVim 终端中运行 git 时,颜色并不难读。我想仅在从 gVim 终端运行时禁用颜色,并且我可以通过设置环境变量(如果存在)来做到这一点。
最佳答案
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
关于git - 如何使用环境变量禁用 git 颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66322214/