git grep 颜色与 grep 自定义颜色不同

Grz*_*cki 12 grep colors configuration git

我已经在我的中设置了 grep 颜色~/.bashrc

export GREP_COLORS='ms=01;34:mc=01;34:sl=:cx=:fn=35:ln=32:bn=32:se=36'
Run Code Online (Sandbox Code Playgroud)

他们为

  • grep --color=auto
  • grep --color=always

不幸的是,这些自定义颜色被忽略:

  • git grep --color=auto
  • git grep --color=always

如何git grep使用以上$GREP_COLORS颜色?

now*_*wox 10

Git grep 没有使用GREP_COLORS环境变量。相反,您应该在您中添加自定义条目~/.gitconfig

例如:

[color "grep"]
    linenumber = yellow bold
    match = red
    filename = magenta     
Run Code Online (Sandbox Code Playgroud)


enz*_*tib 9

您应该在 git 的配置文件中明确配置颜色。

git-config手册页中找到了有趣的信息,特别是查找配置变量color.grep.<slot>