aboutsummaryrefslogtreecommitdiff
path: root/README.md
blob: 923b4afd9752c777fab32f28392255090ab814e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# pwsh-diff

> This project has been "soft-abandoned," because it turns out (perhaps unsurprisingly) that
> `less`-for-Windows has the same limitations as Perl-for-Windows with respect to color control
> codes, and there are really no other suitable pagers. I would consider resuming work on this, were
> a decent Windows-native pager to appear; if you know something I don't, please open an issue!

`pwsh-diff` aims to serve as a PowerShell-based alternative to
[diff-highlight](https://github.com/git/git/tree/master/contrib/diff-highlight)
(and, eventually,
[diff-so-fancy](https://github.com/so-fancy/diff-so-fancy)) on Windows, because Perl and Windows
[don't seem](https://github.com/so-fancy/diff-so-fancy/issues/361)
to
[get along](https://github.com/microsoft/terminal/issues/4738) when it comes to ANSI coloring.

## Installation

Make sure you have PowerShell Core (`pwsh.exe`) in your `PATH` somewhere. Then, copy the `pwsh-diff`
script to a directory in your `PATH`. That's it!

## Usage

Configure Git to use `pwsh-git` for all diff/log output:

```ps
git config --global core.pager "pwsh-diff | less --tabs=4 -RFX"
```

### Improved colors

`pwsh-diff` will read the same color settings expected by `diff-highlight`, and it depends on Git
itself to colorize everything besides the lines with highlighted bits. The following options are
recommended:

```ps
git config --global color.ui true

git config --global color.diff-highlight.oldNormal    "red bold"
git config --global color.diff-highlight.oldHighlight "red bold 52"
git config --global color.diff-highlight.newNormal    "green bold"
git config --global color.diff-highlight.newHighlight "green bold 22"

git config --global color.diff.old "red bold"
git config --global color.diff.new "green bold"
```

## Acknowledgements

Much of the requisite logic has been adapted directly from the aforementioned
[diff-highlight](https://github.com/git/git/tree/master/contrib/diff-highlight)
and
[diff-so-fancy](https://github.com/so-fancy/diff-so-fancy).