1
0
mirror of https://github.com/nix-community/home-manager synced 2024-06-01 04:23:34 +02:00

modules/git: make options passed to less(1) for diff-so-fancy configurable

The `-X` prevents that screen is cleared when showing a diff that's
larger than my screen.

I.e. when running `git diff` and press `q`, the last thing I want to see
is the prompt with `git diff` and *not* the part of the diff I browsed,
to be clear

    $ git diff
    $ <cursor>

Considering that this is somewhat opinionated, I decided to build an
option which allows you to pass arbitrary commands to the less
invocation.
This commit is contained in:
Maximilian Bosch 2023-02-25 20:04:05 +01:00
parent 664945b3e0
commit cccd7622bd
No known key found for this signature in database
GPG Key ID: 9A6EEA275CA5BE0A

View File

@ -340,6 +340,14 @@ in {
'';
};
pagerOpts = mkOption {
type = types.listOf types.str;
default = [ "--tabs=4" "-RFX" ];
description = ''
Arguments to be passed to <command>less</command>.
'';
};
markEmptyLines = mkOption {
type = types.bool;
default = true;
@ -547,7 +555,9 @@ in {
programs.git.iniContent =
let dsfCommand = "${pkgs.diff-so-fancy}/bin/diff-so-fancy";
in {
core.pager = "${dsfCommand} | ${pkgs.less}/bin/less --tabs=4 -RFX";
core.pager = "${dsfCommand} | ${pkgs.less}/bin/less ${
escapeShellArgs cfg.diff-so-fancy.pagerOpts
}";
interactive.diffFilter = "${dsfCommand} --patch";
diff-so-fancy = {
markEmptyLines = cfg.diff-so-fancy.markEmptyLines;