From fd593f85de5ebdfc953925ee1951b84d4895ff71 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 29 Apr 2019 15:49:38 -0400 Subject: bash: GNU diff has `--color=auto` --- .config/bash/rc.d/10_aliases.sh | 29 ++++------------------------- 1 file 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 "$@" -- cgit v1.1-4-g5e80