diff --git a/git-diff-blame b/git-diff-blame index faf7075..49dc710 100755 --- a/git-diff-blame +++ b/git-diff-blame @@ -35,6 +35,10 @@ if ($newrev) { open($diff, '-|', 'git', '--no-pager', 'diff', $oldrev) or die; } +my $istty = -t STDOUT; +my $ANSI_RED = $istty ? "" : ""; +my $ANSI_GRN = $istty ? "" : ""; +my $ANSI_RST = $istty ? "" : ""; my ($pre, $post); my $filename; while (<$diff>) { @@ -79,8 +83,8 @@ while (<$diff>) { print " ", get_blame_prefix(scalar <$pre>), "\t", $_; scalar <$post>; # discard } elsif (m{^\-}) { - print " - ", get_blame_prefix(scalar <$pre>), "\t", $_,""; + print "${ANSI_RED} - ", get_blame_prefix(scalar <$pre>), "\t", $_,"${ANSI_RST}"; } elsif (m{^\+}) { - print " + ", get_blame_prefix(scalar <$post>), "\t", $_,""; + print "${ANSI_GRN} + ", get_blame_prefix(scalar <$post>), "\t", $_,"${ANSI_RST}"; } }