From 2c68dfe11a1b4675b2acb0615603bacf1bdde5d9 Mon Sep 17 00:00:00 2001 From: Sorin Ionescu Date: Wed, 28 Dec 2011 10:34:26 -0500 Subject: [PATCH] Filter brackets in wdiff highlights. --- alias.zsh | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/alias.zsh b/alias.zsh index 3ac3c0c7..68f7a3b1 100644 --- a/alias.zsh +++ b/alias.zsh @@ -91,12 +91,17 @@ if zstyle -t ':omz:alias:diff' color; then } function wdiff() { - if (( $+commands[wdiff] )) && (( $+commands[colordiff] )); then - "$commands[diff]" --unified "$@" | "$commands[wdiff]" --diff-input --avoid-wraps | colordiff --difftype wdiff + if (( $+commands[wdiff] )); then + "$commands[wdiff]" \ + --avoid-wraps \ + --start-delete="$(print -n $FG[red])" \ + --end-delete="$(print -n $FG[none])" \ + --start-insert="$(print -n $FG[green])" \ + --end-insert="$(print -n $FG[none])" \ + "$@" \ + | sed 's/^\(@@\( [+-][[:digit:]]*,[[:digit:]]*\)\{2\} @@\)$/;5;6m\10m/g' elif (( $+commands[git] )); then - git --no-pager diff --color=auto --no-ext-diff --no-index --word-diff "$@" - elif (( $+commands[wdiff] )); then - "$commands[diff]" --unified "$@" | "$commands[wdiff]" --diff-input --avoid-wraps + git --no-pager diff --color=auto --no-ext-diff --no-index --color-words "$@" else print "zsh: command not found: $0" >&2 fi