Show HN: A syntax highlighter for Git and diff output, written in Rust
github.com
github.com
[pager]
log = /Users/user/.bin/diff-highlight | less
show = /Users/user/.bin/diff-highlight | less
diff = /Users/user/.bin/diff-highlight | less
[0]: https://github.com/git/git/tree/master/contrib/diff-highligh...[0] https://github.com/dandavison/delta
[interactive]
diffFilter = delta --color-onlyThe core issue is the same for delta as it is for d-s-f (or any other interactive pager) - there must be a 1:1 correspondence between lines out from git, and lines back into it.
So, delta can do the fancier colouring interactively, but it can't mess with the header either, for the same underlying reason. (And so 'solved' it with a `--color-only` flag.)
[pager]
diff = delta --dark --plus-color="#012800" --minus- color="#340001" --theme="zenburn"EDIT: In fact an issue was opened for this very recently: https://github.com/dandavison/delta/issues/130
Ideally, I think that a mouse click in an appropriate location in a terminal emulator window should open the user's editor on the correct line of the correct file.
⟩ git diff
error: Found argument 'Extended' which wasn't expected, or isn't valid in this context
USAGE:
delta --dark --minus-color <minus_color> --plus-color <plus_color> --theme <theme>
For more information try --help
My ~/.gitconfig file has the copy pasted lines from the github example [core]
pager = delta --dark --plus-color="#012800" --minus-color="#340001" --theme="Monokai Extended"
[interactive]
diffFilter = delta --color-only
Installed with homebrew on macos. --theme='Monokai Extended'
It seems that in ~/.gitconfig, a theme name with spaces must be quoted with single quotes. At least, that is working on MacOS.A tip for people who (like me) don't like that Git pages by default: With Delta, you can disable this it by adding this to your environment:
export BAT_PAGER=catnpm-installed cli which shows you git diff in your browser
1. Delta constructs the side-by-side diff itself (a parsed internal representation of it), and then colorizes it.
2. Delta gains the ability to parse side-by-side diffs being emitted by another tool.
My currently feeling is that (1) is more attractive / easier.
delta --list-themes --dark
and then delta --theme <chosen theme> to select it.This does look nice, though I'm a little confused by the choice to highlight the section below the function declaration change even though it doesnt appear to have a change.
@@ -62,17 +62,17 @@ class MyClass:
Delta makes that more prominent by surrounding it with a box (by default) and getting rid of the for-machines characters that git puts there. It doesn't apply background colors to it though: delta only applies background red and green shading to removed/added lines.(I believe that one can customize the regular expressions that git uses to decide on the hunk header; they're sometimes appropriate and sometimes not, for the languages that I use.)