|
8 | 8 | <p><img align="center" src="https://raw.githubusercontent.com/z-shell/wiki/main/static/img/gif/zsh-diff-so-fancy.gif" alt="zsh-diff-so-fancy" /></p>
|
9 | 9 | </div><hr />
|
10 | 10 |
|
11 |
| -## The `diff-so-fancy` |
| 11 | +# zsh-diff-so-fancy |
12 | 12 |
|
13 |
| -The [so-fancy/diff-so-fancy](https://github.com/so-fancy/diff-so-fancy) as Github submodule. |
| 13 | +A simple plugin integrating [so-fancy/diff-so-fancy](https://github.com/so-fancy/diff-so-fancy) into Zsh. It provides: |
14 | 14 |
|
15 |
| -The plugin has `bin/git-dsf` script which adds subcommand `dsf` to `git`, and `bin/fancy-diff` to pipe the `diff` output to diff-so-fancy. |
| 15 | +- `git dsf`: A subcommand to run Git diffs through diff-so-fancy |
| 16 | +- `fancy-diff`: A helper to run a unified diff and beautify it with diff-so-fancy |
16 | 17 |
|
17 |
| -## Manual configuration |
| 18 | +## Quick Start |
18 | 19 |
|
19 |
| -```shell |
20 |
| -diff-so-fancy --colors # View the commands to set the recommended colors |
21 |
| -diff-so-fancy --set-defaults # Configure git-diff to use diff-so-fancy and suggested colors |
22 |
| -diff-so-fancy --patch # Use diff-so-fancy in patch mode (interoperable with `git add --patch`) |
23 |
| -``` |
| 20 | +1. **Install** [diff-so-fancy](https://github.com/so-fancy/diff-so-fancy#installation) or load it via your preferred method. |
| 21 | +2. **Load the plugin** in your `.zshrc` or plugin manager: |
| 22 | + ```shell |
| 23 | + # Example using Zi |
| 24 | + zi ice as'program' pick'bin/*' |
| 25 | + zi light z-shell/zsh-diff-so-fancy |
| 26 | + ``` |
| 27 | +3. **Use** the commands: |
| 28 | + - `git dsf <files>` to see a diff rendered by diff-so-fancy |
| 29 | + - `fancy-diff <file1> <file2>` to compare two files with diff-so-fancy |
24 | 30 |
|
25 |
| -```shell |
26 |
| -# Configure git to use d-s-f for *all* diff operations |
27 |
| -git config --global core.pager "diff-so-fancy | less --tabs=4 -RFX" |
28 |
| -``` |
| 31 | +## Manual Configuration |
29 | 32 |
|
30 | 33 | ```shell
|
31 |
| -# Configure git to use d-s-f for `git add --patch` |
32 |
| -git config --global interactive.diffFilter "diff-so-fancy --patch" |
| 34 | +diff-so-fancy --colors # Show recommended color config |
| 35 | +diff-so-fancy --set-defaults # Configure Git to use diff-so-fancy with suggested colors |
| 36 | +diff-so-fancy --patch # Patch mode, interoperable with `git add --patch` |
33 | 37 | ```
|
34 | 38 |
|
35 |
| -### Options |
36 |
| - |
37 |
| -#### markEmptyLines |
38 |
| - |
39 |
| -Should the first block of an empty line be colored. (Default: true) |
| 39 | +### Git Integration |
40 | 40 |
|
41 | 41 | ```shell
|
42 |
| -git config --bool --global diff-so-fancy.markEmptyLines false |
43 |
| -``` |
44 |
| - |
45 |
| -#### changeHunkIndicators |
46 |
| - |
47 |
| -Simplify git header chunks to a more human readable format. (Default: true) |
48 |
| - |
49 |
| -```shell |
50 |
| -git config --bool --global diff-so-fancy.changeHunkIndicators false |
51 |
| -``` |
52 |
| - |
53 |
| -#### stripLeadingSymbols |
54 |
| - |
55 |
| -Should the pesky `+` or `-` at line-start be removed. (Default: true) |
56 |
| - |
57 |
| -```shell |
58 |
| -git config --bool --global diff-so-fancy.stripLeadingSymbols false |
59 |
| -``` |
60 |
| - |
61 |
| -#### useUnicodeRuler |
62 |
| - |
63 |
| -By default, the separator for the file header uses Unicode line-drawing characters. If this is causing output errors on your terminal, set this to `false` to use ASCII characters instead. (Default: true) |
64 |
| - |
65 |
| -```shell |
66 |
| -git config --bool --global diff-so-fancy.useUnicodeRuler false |
67 |
| -``` |
68 |
| - |
69 |
| -#### rulerWidth |
70 |
| - |
71 |
| -By default, the separator for the file header spans the full width of the terminal. Use this setting to set the width of the file header manually. |
| 42 | +# Use diff-so-fancy for all diffs |
| 43 | +git config --global core.pager "diff-so-fancy | less --tabs=4 -RFX" |
72 | 44 |
|
73 |
| -```shell |
74 |
| -git config --global diff-so-fancy.rulerWidth 47 # git log's commit header width |
| 45 | +# Use diff-so-fancy for `git add --patch` |
| 46 | +git config --global interactive.diffFilter "diff-so-fancy --patch" |
75 | 47 | ```
|
76 | 48 |
|
77 |
| -## Install with [Zi](https://github.com/z-shell/zi) |
| 49 | +### diff-so-fancy Options |
78 | 50 |
|
79 |
| -The project [so-fancy/diff-so-fancy](https://github.com/so-fancy/diff-so-fancy) integration with Zi. |
| 51 | +- **markEmptyLines** (bool, default: true) |
| 52 | + Color the first block of an empty line. |
| 53 | +- **changeHunkIndicators** (bool, default: true) |
| 54 | + Simplify Git header chunks to a more readable format. |
| 55 | +- **stripLeadingSymbols** (bool, default: true) |
| 56 | + Remove leading `+` or `-` from lines. |
| 57 | +- **useUnicodeRuler** (bool, default: true) |
| 58 | + Use Unicode line-drawing characters for file headers (disable if your terminal cannot display them). |
| 59 | +- **rulerWidth** (int, default: full width) |
| 60 | + Set a fixed width for the file header separator. |
80 | 61 |
|
81 |
| -Simply add two lines to `.zshrc`: |
82 |
| - |
83 |
| -Using [bin-gem-node](https://wiki.zshell.dev/ecosystem/annexes/bin-gem-node) annex (recommended): |
| 62 | +### Installation with [Zi](https://github.com/z-shell/zi) |
84 | 63 |
|
85 | 64 | ```shell
|
86 | 65 | zi ice as'null' sbin'bin/*'
|
87 | 66 | zi light z-shell/zsh-diff-so-fancy
|
88 | 67 | ```
|
89 | 68 |
|
90 |
| -Default: |
| 69 | +Or: |
91 | 70 |
|
92 | 71 | ```shell
|
93 | 72 | zi ice as'program' pick'bin/*'
|
94 | 73 | zi light z-shell/zsh-diff-so-fancy
|
95 | 74 | ```
|
96 | 75 |
|
97 |
| -This will add `diff-so-fancy`, `fancy-diff`, `git-dsf` to `$PATH` and automatically equip `git` with subcommand `dsf`. |
98 |
| - |
99 |
| -**No need to use the system package manager or manually configure** `git`, however, if you have the following standard line in your `.gitconfig`, it will still work as expected: |
100 |
| - |
101 |
| -```ini |
102 |
| -[core] |
103 |
| - pager = diff-so-fancy | less --tabs=4 -RFX |
104 |
| -[interactive] |
105 |
| - diffFilter = diff-so-fancy --patch |
106 |
| -``` |
107 |
| - |
108 |
| -## Other plugin managers |
109 |
| - |
110 |
| -### Zplug |
111 |
| - |
112 |
| -```shell |
113 |
| -zplug "z-shell/zsh-diff-so-fancy", as:command, use:"bin/" |
114 |
| -``` |
115 |
| - |
116 |
| -### Zgen |
| 76 | +This places `diff-so-fancy`, `fancy-diff`, and `git-dsf` in `$PATH`, adding the `dsf` subcommand to Git automatically. |
117 | 77 |
|
118 |
| -```shell |
119 |
| -zgen load z-shell/zsh-diff-so-fancy |
120 |
| -``` |
| 78 | +## Other Plugin Managers |
121 | 79 |
|
122 |
| -Without `as"program"`-like functionality the `.plugin.zsh` file picks up setup |
123 |
| -and simulates adding a command to the system, so `Zgen` and others can work. |
| 80 | +- **Zplug** |
| 81 | + ```shell |
| 82 | + zplug "z-shell/zsh-diff-so-fancy", as:command, use:"bin/" |
| 83 | + ``` |
| 84 | +- **Zgen** |
| 85 | + ```shell |
| 86 | + zgen load z-shell/zsh-diff-so-fancy |
| 87 | + ``` |
0 commit comments