How can I 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 old.txt new.txt --no-index.)git diff --no-index --color-words--no-index and --color-words does not matter... (Actually I can't find a case now where it fails without --no-index at all).alias diff="git diff --no-index"?According to a comment from Jefromi you can just use
git diff --color-words file1 file2 outside of git repositories too.
git diff --color-words --no-index <file1> <file2> works, correct approach would be to use wdiff, which is intended for that purpose (gnu.org/software/wdiff)git diff is intended for this purpose. wdiff is just a hack. Read your link sometime.git diff is excellent, but the wdiff page noted above does not say that it's a hack. wdiff "is quite mature" according to its own documentation linked from that page: gnu.org/software/wdiff/manual/wdiff.htmlIf 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 argumentsUsing 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 : https://www.gnu.org/software/wdiff/manual/html_node/wdiff-Examples.html (modified to use foreground colors rather than background colors)
Hope it helps.
git --no-index --color-words fails? I used it (with earlier Git versions although).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 …
--color-words=always instead of just --color-words.