wdiff 912 B

123456789101112131415161718192021222324252627282930313233
  1. #
  2. # Highlights wdiff output.
  3. #
  4. # Authors:
  5. # Sorin Ionescu <sorin.ionescu@gmail.com>
  6. # Indrajit Raychaudhuri <irc@indrajit.com>
  7. #
  8. # function wdiff {
  9. if zstyle -t ':prezto:module:utility:wdiff' color; then
  10. if (( $+commands[wdiff] )); then
  11. command wdiff \
  12. --avoid-wraps \
  13. --start-delete="$(print -n $FG[red])" \
  14. --end-delete="$(print -n $FG[none])" \
  15. --start-insert="$(print -n $FG[green])" \
  16. --end-insert="$(print -n $FG[none])" \
  17. "$@" \
  18. | sed 's/^\(@@\( [+-][[:digit:]]*,[[:digit:]]*\)\{2\} @@\)$/;5;6m\10m/g'
  19. elif (( $+commands[git] )); then
  20. command git --no-pager diff --no-ext-diff --no-index --color=auto --color-words "$@"
  21. else
  22. command wdiff "$@"
  23. fi
  24. elif (( ! $+commands[wdiff] && $+commands[git] )); then
  25. command git --no-pager diff --no-ext-diff --no-index --color=never "$@"
  26. else
  27. command wdiff "$@"
  28. fi
  29. # }