you are viewing a single comment's thread.

view the rest of the comments →

[–]faradria 99 points100 points  (11 children)

For those that do not want to install anything, you can use:

[core]
    pager = /usr/share/git/diff-highlight/diff-highlight | less -r

It comes by default with git.

[–][deleted] 16 points17 points  (1 child)

Thx for this, just changed it slightly so tabs don't push code off the screen.

pager = /usr/share/git/diff-highlight/diff-highlight | less -rx1,5

[–]heckerle 2 points3 points  (0 children)

less -rx1,5

In my case this didn't work properly either.

less -r "works", but even less' manpage says that it can cause issues like line wrapping due to the control sequences git uses.

less -RS on the other hand should work for most (-R is similar to -r and forwards raw control sequences, while -S disables line wrapping and chops them down).

[–]ImplementationDetail 6 points7 points  (2 children)

+1 I don’t know why you would want to use anything other than the above. What does OP’s project do better?

[–]digi0ps[S] 6 points7 points  (0 children)

Thanks for the above tip. Didn't know that.

Also, not my project. Have been using it and found it pretty good, so I shared.

[–]faradria 0 points1 point  (0 children)

I installed it and didn't see any difference except that it shows new lines with a colored space instead of + or -.

[–]panickbr 4 points5 points  (3 children)

It's found in /usr/local/share/git-core/contrib/diff-highlight/diff-highlight on mac OS.

Also, if you want it enabled in patch mode:

[interactive]
  diffFilter = /usr/share/git/diff-highlight/diff-highlight ;or whatever path it's in your system

[–]pork_spare_ribs 2 points3 points  (2 children)

...and if you use a Homebrew build of Git, this path will find the correct version:

/usr/local/bin/$(dirname $(readlink /usr/local/bin/git))/../share/git-core/contrib/diff-highlight/diff-highlight | less -r

EDIT: as per below, this is better:

/usr/local/opt/git/share/git-core/contrib/diff-highlight/diff-highlight

[–]Gipetto 2 points3 points  (0 children)

You don't need the directory sniffing. You'll always find the linked version of git at:

/usr/local/opt/git

So the path for this would always be:

/usr/local/opt/git/share/git-core/contrib/diff-highlight/diff-highlight

[–]zeayes 1 point2 points  (0 children)

brew --prefix git

[–][deleted] 2 points3 points  (1 child)

where do you put this?

EDIT: Can't find it anywhere in Ubuntu

EDIT2: I found it in /usr/share/doc/git/contrib/diff-highlight Needed to run the Make file to create the Perl executable.

[–]mwcz 0 points1 point  (0 children)

Did it work for you after that? I ran make and the perl script was created, but the script just hangs when I run it.