How to use `git diff --color-words` outside a Git repository?

How to get output like in git diff --color-words, but outside Git?

Closest thing is wdiff -t, but it underlines/inverts things instead of using green/red colours and does not allow specifying my whitespace regex.


git diff --color-words --no-index

According to a comment from Jefromi you can just use

git diff --color-words file1 file2

outside of git repositories too.

Git version 1.9.1:

git diff --word-diff=color fileA fileB

you can say git diff --color=always --color-words, which will give you the color escape codes in the output. you are going to have some shell to interpret the color codes though …

If I'm inside a git repository (git v2.3.3) :

  • git diff --color-words doesn't work (no output)
  • git diff --no-index doesn't accept --color-words nor --color arguments

Using wdiff is possible, configured to use colors, rather than underlined :

wdiff -n \
  -w $'\033[30;31m' -x $'\033[0m' \
  -y $'\033[30;32m' -z $'\033[0m' \
  … | less -R

Source : (modified to use foreground colors rather than background colors)

Hope it helps.

Need Your Help

Make the java systray look prettier in Linux

java swing systray

I'm making a Java Application on Linux that uses sytray using Java 6 and Swing. The app looks great (uses the system look and feel) but the systray looks awful. I mean the systray menu looks like old

How to correctly set HTTP header with managed IIS module

c# .net iis arr

I've written my own managed IIS HTTP-module in C#. It's purpose is to simply set X-Forwarded-For and X-Forwarded-Proto request headers on some condition (which can not be handled with routing rules...