Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set up a different pager and color mode in Mercurial?

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:

  • No ANSI escape codes in output.
  • Use https://github.com/dandavison/delta as a pager.

Is it possible to configure Mercurial this way?

like image 311
Petr Avatar asked Oct 12 '25 10:10

Petr


1 Answers

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.

like image 73
Petr Avatar answered Oct 16 '25 09:10

Petr