这里介绍两种 Git Bash下grep命令检索内容高亮的方法。
简单的方法
添加 --color
参数即可实现检索内容高亮:
cat 1.txt | grep 666 --color
一劳永逸,为命令取别名
打开Git\etc\profile.d\aliases.sh
添加 alias grep='grep --color'
重启bash
附,我的aliases.sh文件:
# Some good standards, which are not used if the user
# creates his/her own .bashrc/.bash_profile
# --show-control-chars: help showing Korean or accented characters
alias ls='ls -F --color=auto --show-control-chars'
alias ll='ls -l'
# grep 检索高亮
alias grep='grep --color'
case "$TERM" in
xterm*)
# The following programs are known to require a Win32 Console
# for interactive usage, therefore let's launch them through winpty
# when run inside `mintty`.
for name in node ipython php php5 psql python2.7
do
case "$(type -p "$name".exe 2>/dev/null)" in
''|/usr/bin/*) continue;;
esac
alias $name="winpty $name.exe"
done
;;
esac