I handle this in a way that is more agnostic to the type of revision control, and fully flexible in coloring (using the most powerful scheme available).<p>For example, I shouldn&#x27;t have to put up with basic colors if the terminal can do better.<p>Here is how it works; starting with:<p><pre><code>  #!&#x2F;bin&#x2F;bash 
  if [ -r &quot;.svn&quot; ] ; then
    exec svn diff ${1+&quot;$@&quot;} | my_colorize_diff
  else
    git diff ${1+&quot;$@&quot;} | my_colorize_diff
  fi
</code></pre>
...where the &quot;my_colorize_diff&quot; script at the end of the pipe is as follows:<p><pre><code>  #!&#x2F;usr&#x2F;bin&#x2F;env perl
  # by Kevin Grant (kmg@mac.com)
  my $term_program = (exists $ENV{&#x27;TERM_PROGRAM&#x27;} &amp;&amp; defined $ENV{&#x27;TERM_PROGRAM&#x27;}) ? $ENV{&#x27;TERM_PROGRAM&#x27;} : &#x27;&#x27;;
  my $term = (exists $ENV{&#x27;TERM&#x27;} &amp;&amp; defined $ENV{&#x27;TERM&#x27;}) ? $ENV{&#x27;TERM&#x27;} : &#x27;vt100&#x27;;
  my $is_xterm = ($term =~ &#x2F;xterm&#x2F;);
  my $is_24bit = ($term_program =~ &#x2F;MacTerm&#x2F;);
  print &quot;\033#3BEGIN DIFF\n&quot;;
  print &quot;\033#4BEGIN DIFF\n\033#5&quot;;
  while (&lt;&gt;) {
    if (&#x2F;^\+&#x2F; &amp;&amp; !&#x2F;^\+\+&#x2F;) {
      if ($is_24bit) {
        print &quot;\033[48:2:150:200:150m&quot;, &quot;\033[2K&quot;, &quot;\033[38:2::88:m&quot;, &quot;\033[1m&quot;;
      } elsif ($is_xterm) {
        print &quot;\033[48;5;149m&quot;, &quot;\033[2K&quot;, &quot;\033[38;5;235m&quot;, &quot;\033[1m&quot;;
      } else {
        print &quot;\033[42m&quot;, &quot;\033[2K&quot;, &quot;\033[30m&quot;, &quot;\033[1m&quot;;
      }
    } elsif (&#x2F;^\-&#x2F; &amp;&amp; !&#x2F;^\-\-&#x2F;) {
      if ($is_24bit) {
        print &quot;\033[48:2:244:150:150m&quot;, &quot;\033[2K&quot;, &quot;\033[38:2:144:0::m&quot;;
      } elsif ($is_xterm) {
        print &quot;\033[48;5;52m&quot;, &quot;\033[2K&quot;, &quot;\033[38;5;124m&quot;;
      } else {
        print &quot;\033[41m&quot;, &quot;\033[2K&quot;, &quot;\033[37m&quot;;
      }
    } else {
      print &quot;\033[3m&quot;;
    }
    chomp;
    print;
    print &quot;\033[0m\n&quot;;
  }
  print &quot;\033#3END DIFF\n&quot;;
  print &quot;\033#4END DIFF\n\033#5&quot;;</code></pre>