Adding color to git diff output.
- From
sean <seanlkml@sympatico.ca>
- Date
- Apr 11, 2006, 22:32 UTC
- Message-ID
- <BAYC1-PASMTP08B0DB32592225AAD0838AAECD0@CEZ.ICE>
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"