summaryrefslogtreecommitdiff
path: root/.config
diff options
context:
space:
mode:
Diffstat (limited to '.config')
-rw-r--r--.config/bash/rc.d/10_aliases.sh42
1 files changed, 26 insertions, 16 deletions
diff --git a/.config/bash/rc.d/10_aliases.sh b/.config/bash/rc.d/10_aliases.sh
index da214e9..2e28a5d 100644
--- a/.config/bash/rc.d/10_aliases.sh
+++ b/.config/bash/rc.d/10_aliases.sh
@@ -22,15 +22,20 @@ if [ -x "`which dircolors`" ]; then
wdiff() {
if [[ -t 1 ]]; then
- local red="$(tput setaf 1)"
- local blue="$(tput setaf 4)"
- local bold="$(tput bold)"
- local reset="$(tput sgr0)"
+ 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
command wdiff \
- -w "$bold$red[-" \
- -x "-]$reset" \
- -y "$bold$blue{+" \
- -z "+}$reset" "$@"
+ -w "$old[-" \
+ -x "-]$off" \
+ -y "$new{+" \
+ -z "+}$off" \
+ "$@"
else
command wdiff "$@"
fi
@@ -38,15 +43,20 @@ if [ -x "`which dircolors`" ]; then
chardiff() {
if [[ -t 1 ]]; then
- local red="$(tput setaf 1)"
- local blue="$(tput setaf 4)"
- local bold="$(tput bold)"
- local reset="$(tput sgr0)"
+ 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
command chardiff \
- -w "$bold$red[-" \
- -x "-]$reset" \
- -y "$bold$blue{+" \
- -z "+}$reset" "$@"
+ -w "$old[-" \
+ -x "-]$off" \
+ -y "$new{+" \
+ -z "+}$off" \
+ "$@"
else
command chardiff "$@"
fi