3

I set up Mercurial in .hgrc to use less as a pager together with customized colors and templates following this guide:

[pager]
pager = LESS='FSrX' less

[templates]
# ...

[color]
mode=terminfo

This works very nicely and I'd like to keep this for all commands except for hg diff. For this command only I'd like to use a completely different mechanism:

Is it possible to configure Mercurial this way?

Petr
  • 62,528
  • 13
  • 153
  • 317

2 Answers2

3

I found a solution here which achieves this setup using the extdiff extension.

[extensions]
hgext.extdiff =

[extdiff]
cmd.delta =

[alias]
diff = delta

Earlier I had this workaround - to create a separate alias:

[alias]
d = !$HG diff "$@" | delta

Unfortunately it's not possible to replace the original diff command this way. While it's possible (although discouraged) to replace a command with an alias, in this case it doesn't work: Invoking $HG diff from a diff alias would cause an infinite loop.

Petr
  • 62,528
  • 13
  • 153
  • 317
2
  • Beware of using manuals for Mercurial from 2014 in 2022, they can be outdated and just irrelevant

  • Correct using less now as pager will be (without artefacts of pager extension)

    [pager]
    pager = less -FRX
    
  • According to hg help pager in fresh HG (6.2), you can, with active pager, disable using it for some command(s)

You can disable the pager for certain commands by adding them to the pager. Ignore list

i.e. have smth. like

  [pager]
  ignore = diff

and get diff totally without paging

  • From the other side (contrary to the above point), you can use --config

set/override config option (use 'section.name=value')

option on calling hg diff (when|if you'll have delta as working pager) and for simplicity create hg-alias for "hg diff with delta" like

  ddiff = diff --config pager.pager=delta $@
Lazy Badger
  • 94,711
  • 9
  • 78
  • 110