Skip to content

Commit 85c7b28

Browse files
stkstefanhaller
authored andcommitted
Add documentation for pager workaround on Windows
1 parent 3372e2b commit 85c7b28

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

docs/Custom_Pagers.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Lazygit supports custom pagers, [configured](/docs/Config.md) in the config.yml file (which can be opened by pressing `e` in the Status panel).
44

5-
Support does not extend to Windows users, because we're making use of a package which doesn't have Windows support.
5+
Support does not extend to Windows users, because we're making use of a package which doesn't have Windows support. However, see [below](#emulating-custom-pagers-on-windows) for a workaround.
66

77
## Default:
88

@@ -84,3 +84,30 @@ git:
8484
```
8585

8686
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.
87+
88+
## Emulating custom pagers on Windows
89+
90+
There is a trick to emulate custom pagers on Windows using a Powershell script configured as an external diff command. It's not perfect, but certainly better than nothing. To do this, save the following script as `lazygit-pager.ps1` at a convenient place on your disk:
91+
92+
```pwsh
93+
#!/usr/bin/env pwsh
94+
95+
$old = $args[1].Replace('\', '/')
96+
$new = $args[4].Replace('\', '/')
97+
$path = $args[0]
98+
git diff --no-index --no-ext-diff $old $new
99+
| %{ $_.Replace($old, $path).Replace($new, $path) }
100+
| delta --width=$env:LAZYGIT_COLUMNS
101+
```
102+
103+
Use the pager of your choice with the arguments you like in the last line of the script. Personally I wouldn't want to use lazygit anymore without delta's `--hyperlinks --hyperlinks-file-link-format="lazygit-edit://{path}:{line}"` args, see [above](#delta).
104+
105+
In your lazygit config, use
106+
107+
```yml
108+
git:
109+
paging:
110+
externalDiffCommand: "C:/wherever/lazygit-pager.ps1"
111+
```
112+
113+
The main limitation of this approach compared to a "real" pager is that renames are not displayed correctly; they are shown as if they were modifications of the old file. (This affects only the hunk headers; the diff itself is always correct.)

0 commit comments

Comments
 (0)