#!/usr/bin/env zsh

# Load colors helpers
autoload -U colors && colors

function colorize_diff {
    while read line; do
    case ${line[0]} in
    +) print -n $fg[green];;
    -) print -n $fg[red];;
    @) # Display in cyan the @@ positions @@
       if [[ ${line[1]} = '@' ]]; then
           line=$(print $line | perl -pe 's#(\@\@[^\@]*\@\@)(.*)$#'$fg[cyan]'$1'$reset_color'$2#')
       fi;;

    esac
        print -- $line
        print -n $reset_color
        done
}

diff -u $* | colorize_diff
