我最近发现,在Mac OS XI上可以在外壳中进行设置,~/.profile以便在使用grep时以彩色(白色到红色)打印匹配项。
alias grep='GREP_COLOR="1;37;41" LANG=C grep --color=auto'
但是设置别名似乎是一种破解方法。以前我没有运气就尝试过:
export GREP_COLOR=always # works fine in Linux
然后我还尝试了:
export GREP_COLOR="1;37;41"
有没有比设置别名更好的方法呢?
export环境变量,例如in中.bash_profile,然后定义alias grep='grep --color',您就完成了。