This is similar to using lazygit's Git.Paging.ExternalDiffCommand config, except that the command is configured in git. This can be done either with git's `diff.external` config, or through .gitattributes, so it gives a bit more flexibility.
2.8 KiB
Custom Pagers
Lazygit supports custom pagers, configured in the config.yml file (which can be opened by pressing e
in the Status panel).
Support does not extend to Windows users, because we're making use of a package which doesn't have Windows support.
Default:
git:
paging:
colorArg: always
the colorArg
key is for whether you want the --color=always
arg in your git diff
command. Some pagers want it set to always
, others want it set to never
.
Delta:
git:
paging:
colorArg: always
pager: delta --dark --paging=never
A cool feature of delta is --hyperlinks, which renders clickable links for the line numbers in the left margin, and lazygit supports these. To use them, set the pager:
config to delta --dark --paging=never --line-numbers --hyperlinks --hyperlinks-file-link-format="lazygit-edit://{path}:{line}"
; this allows you to click on an underlined line number in the diff to jump right to that same line in your editor.
Diff-so-fancy
git:
paging:
colorArg: always
pager: diff-so-fancy
ydiff
gui:
sidePanelWidth: 0.2 # gives you more space to show things side-by-side
git:
paging:
colorArg: never
pager: ydiff -p cat -s --wrap --width={{columnWidth}}
Be careful with this one, I think the homebrew and pip versions are behind master. I needed to directly download the ydiff script to get the no-pager functionality working.
Using external diff commands
Some diff tools can't work as a simple pager like the ones above do, because they need access to the entire diff, so just post-processing git's diff is not enough for them. The most notable example is probably difftastic.
These can be used in lazygit by using the externalDiffCommand
config; in the case of difftastic, that could be
git:
paging:
externalDiffCommand: difft --color=always
The colorArg
and pager
options are not used in this case.
You can add whatever extra arguments you prefer for your difftool; for instance
git:
paging:
externalDiffCommand: difft --color=always --display=inline --syntax-highlight=off
Instead of setting this command in lazygit's externalDiffCommand
config, you can also tell lazygit to use the external diff command that is configured in git itself (diff.external
), by using
git:
paging:
useExternalDiffGitConfig: true
This can be useful if you also want to use it for diffs on the command line, and it also has the advantage that you can configure it per file type in .gitattributes
; see https://git-scm.com/docs/gitattributes#_defining_an_external_diff_driver.