在 Linux 上,我获得了漂亮的色彩,使得文件名和行号很容易与文件内容区分开来:
我在 Mac OS X 上设置了GREP_COLORS
GNU grep 安装(通过 homebrew),但它被忽略了。我只得到了匹配文本的颜色,而且颜色比较有限。
版本信息
/Volumes/numerous/usr/local/homebrew/opt/grep/libexec/gnubin/grep --version
grep (GNU grep) 3.7
Packaged by Homebrew
Copyright (C) 2021 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Mike Haertel and others; see
<https://git.sv.gnu.org/cgit/grep.git/tree/AUTHORS>.
GREP_COLORS='ms=01;31:mc=01;31:sl=:cx=:fn=35:ln=32:bn=32:se=36'
不正确的答案
使用--color=always
。我不是在谈论突出显示匹配项。我在谈论组件着色。