diff options
author | Luke Shumaker <lukeshu@datawire.io> | 2019-04-29 15:49:38 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@datawire.io> | 2019-04-29 15:49:38 -0400 |
commit | fd593f85de5ebdfc953925ee1951b84d4895ff71 (patch) | |
tree | 48cdb99a1d98cad77f6655b65bc828c1e69ef436 | |
parent | 4e8977295a94498a22a98c8ecf7915608bd60cf2 (diff) |
bash: GNU diff has `--color=auto`
-rw-r--r-- | .config/bash/rc.d/10_aliases.sh | 29 |
1 files changed, 4 insertions, 25 deletions
diff --git a/.config/bash/rc.d/10_aliases.sh b/.config/bash/rc.d/10_aliases.sh index 9d008e2..233be06 100644 --- a/.config/bash/rc.d/10_aliases.sh +++ b/.config/bash/rc.d/10_aliases.sh @@ -26,16 +26,12 @@ if type dircolors &>/dev/null; then done unset xgrep + alias diff='diff --color=auto' + wdiff() { if [[ -t 1 ]]; then local old new off - if type colordiff &>/dev/null; then - eval "$(colordiff <(echo old) <(echo new)|sed -rn 's@(.*)[<>] (old|new)(.*)@\2='\''\1'\''\noff='\''\3'\''\n@p')" - else - new="$(tput setaf 2)" - old="$(tput setaf 1)" - off="$(tput sgr0)" - fi + eval "$(diff --color=always <(echo old) <(echo new)|sed -rn 's@(.*)[<>] (old|new)(.*)@\2='\''\1'\''\noff='\''\3'\''\n@p')" command wdiff \ -w "$old[-" \ -x "-]$off" \ @@ -50,13 +46,7 @@ if type dircolors &>/dev/null; then chardiff() { if [[ -t 1 ]]; then local old new off - if type colordiff &>/dev/null; then - eval "$(colordiff <(echo old) <(echo new)|sed -rn 's@(.*)[<>] (old|new)(.*)@\2='\''\1'\''\noff='\''\3'\''\n@p')" - else - new="$(tput setaf 2)" - old="$(tput setaf 1)" - off="$(tput sgr0)" - fi + eval "$(diff --color=always <(echo old) <(echo new)|sed -rn 's@(.*)[<>] (old|new)(.*)@\2='\''\1'\''\noff='\''\3'\''\n@p')" command chardiff \ -w "$old[-" \ -x "-]$off" \ @@ -68,17 +58,6 @@ if type dircolors &>/dev/null; then fi } - diff() { - if [[ -t 1 ]] && type colordiff &>/dev/null; then - ( - set -o pipefail - command diff "$@" | colordiff - ) - else - command diff "$@" - fi - } - diffstat() { if [[ -t 1 ]]; then command diffstat -C "$@" |