效果如图:
准备:
sudo apt-get install colordiff # 安装 colordiff
命令:
diff -u a.txt b.txt | colordiff
还可以写成shell来代替默认的diff:
if [ -z $1 ] || [ -z $2 ]
then
echo "缺少参数,例:"
echo " diff a.txt b.txt"
else
diff $1 $2 | colordiff
fi
以上内容另存为diff.sh,然后在~/.bashrc
中增加
alias='bash ./diff.sh' #diff.sh的路径以实际为准