我已经设置了差异突出显示作为 git 的寻呼机/荧光笔。
[pager]
log = diff-highlight | less
show = diff-highlight | less
diff = diff-highlight | less
效果很好。
但是如何将 diff-highlight 用于普通 diff 呢?
答案1
您可以定义一个函数:
diff() { /usr/bin/diff "$@" | diff-highlight }
diff-highlight
处理统一的差异(diff -u
),但管道其他格式似乎可以工作——它不变地传递它们。
为了近似你得到的行为git diff
,你需要colordiff
也:
diff() { colordiff -u "$@" | diff-highlight | less -FRX }