Re: Adding color to git diff output.

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

 




On Tue, 11 Apr 2006, sean wrote:
> 
> What I have is a script ~/bin/gitcdiff:
> 
> #!/bin/sh
> tty -s <&1 || exec cat
> colordiff | less -RS
> 
> And then setting GIT_DIFF_PAGER="~/bin/gitcdiff".  When piping to a file 
> it just uses cat, but when the output is a terminal device it uses the 
> colordiff.
> 
> I thought about integrating that logic into git-diff.sh, but i'm not sure
> it's always appropriate.

Yeah, that's close to what I'd have suggested:

		Linus

----
diff --git a/git-diff.sh b/git-diff.sh
index dc0dd31..f0bea80 100755
--- a/git-diff.sh
+++ b/git-diff.sh
@@ -69,4 +69,8 @@ case "$rev" in
 	;;
 esac
 
+if [ "$GIT_DIFF_PAGER" ] && tty -s <&1; 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]