Adding color to git diff output.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Linus posted a colorize program a while back[1] but it wasn't taken into git.  
The patch below takes a different approach, adding a GIT_DIFF_PAGER variable.
You can use it by assigning a filter to the environment variable, like so:

export GIT_DIFF_PAGER="colordiff | less -RS"

Sean

P.S.  .gitignore is missing a few entries: "git.spec" (rpm build), "tags" 
      (ctags), and ".*.swp" (vi editor temp files).

[1] http://marc.theaimsgroup.com/?l=git&m=114315063918024&w=2


diff --git a/git-diff.sh b/git-diff.sh
index dc0dd31..f792340 100755
--- a/git-diff.sh
+++ b/git-diff.sh
@@ -69,4 +69,8 @@ case "$rev" in
 	;;
 esac
 
+if [ -n "$GIT_DIFF_PAGER" ]; then
+	cmd="$cmd | $GIT_DIFF_PAGER"
+fi
+
 eval "$cmd"
-
: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]