Normally, our terminal git diffs look like this.
Let’s improve our experience by adding syntax highlighting!
To accomplish this, we’re going to replace the pager that git uses with a tool called delta. Add the following to
[core] pager = "delta"
Let’s see what our git diffs look like now.
This looks great, but I think we can do even better. Let’s configure
delta to use the same theme as our terminal.
delta uses bat for syntax highlighting, so we can use any theme that
bat can use.
Grab your theme (you’ll have to find a TextMate/Sublime Text version of it), copy it into
~/.config/bat/themes, and add the following option to your pager configuration.
[core] pager = "delta --theme='Forest Night'"
Now, the highlighting blends seamlessly with the rest of my development experience.
One last improvement you can make is to use the same diff colors that your theme uses. I copied them from the theme file and added the following options to my pager configuration.
[core] pager = "delta --plus-color=\"#333B2F\" --minus-color=\"#382F32\" --theme='Forest Night'"
Okay, now that our diffs look good, we can finally get back to work 😄.