Git

使用 ‘diff-highlight’ 表示差異

  • February 6, 2019

我已經將diff-highlight設置為 git 的尋呼機/熒光筆。

[pager]
   log = diff-highlight | less
   show = diff-highlight | less
   diff = diff-highlight | less

這完美無缺。

但是如何將 diff-highlight 用於普通 diff ?

您可以定義一個函式:

diff() { /usr/bin/diff "$@" | diff-highlight }

diff-highlight處理統一的差異(diff -u)但管道其他格式似乎工作 - 它通過它們不變。

為了近似你得到的行為git diff,你還需要colordiff

diff() { colordiff -u "$@" | diff-highlight | less -FRX }

引用自:https://unix.stackexchange.com/questions/498965