Reputation: 10811
Is there a way to disable git colors using an environment variable?
Normally when I run git, I want the output colorized. Therefore, my .gitconfig has:
[color]
ui = auto
However, when running git from within a gVim terminal, the colors don't are hard to read. I would like to disable the colors only when running from a gVim terminal, and I could do this by setting an environment variable if one exists.
Upvotes: 2
Views: 402
Reputation: 196476
You can simply change GVim's terminal colors with g:terminal_ansi_colors
variable, the value of which is expected to be a list of 16 hexadecimal colors, corresponding to the 16 so-called "ANSI colors":
let g:terminal_ansi_colors = [
\ '#1c1c1c',
\ '#af5f5f',
\ '#5f875f',
\ '#87875f',
\ '#5f87af',
\ '#5f5f87',
\ '#5f8787',
\ '#6c6c6c',
\ '#444444',
\ '#ff8700',
\ '#87af87',
\ '#ffffaf',
\ '#8fafd7',
\ '#8787af',
\ '#5fafaf',
\ '#ffffff',
\ ]
The value above is taken from my colorscheme; feel free to use whatever works for you.
Upvotes: 1
Reputation: 10811
GIT_CONFIG_PARAMETERS="'color.ui=never'"
While I have not found documentation for this, it is covered by a 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
Upvotes: 1