简体   繁体   English

如何在 Mercurial 中设置不同的寻呼机和颜色模式?

[英]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 :我在.hgrc中设置了 Mercurial 以使用less作为寻呼机以及自定义 colors 和遵循本指南的模板:

[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 .这很好用,我想为除hg diff之外的所有命令保留它。 For this command only I'd like to use a completely different mechanism:仅对于此命令,我想使用完全不同的机制:

Is it possible to configure Mercurial this way?可以这样配置 Mercurial 吗?

I found a solution here which achieves this setup using the extdiff extension .我在这里找到了一个解决方案,它使用extdiff扩展来实现这个设置。

[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.不幸的是,无法以这种方式替换原始的diff命令。 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.虽然可以(尽管不鼓励)用别名替换命令,但在这种情况下它不起作用:从diff别名调用$HG diff会导致无限循环。

  • Beware of using manuals for Mercurial from 2014 in 2022, they can be outdated and just irrelevant从 2014 年到 2022 年,请注意使用 Mercurial 的手册,它们可能已经过时并且无关紧要

  • Correct using less now as pager will be (without artefacts of pager extension)正确使用less现在作为寻呼机将(没有寻呼机扩展的伪影)

     [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)根据 Fresh HG (6.2) 中的hg help pager ,您可以使用活动寻呼机禁用某些命令使用它

You can disable the pager for certain commands by adding them to the pager. Ignore您可以通过将某些命令添加到寻呼机来禁用pager. Ignore pager. Ignore list pager. Ignore列表

ie have smth.即有smth。 like喜欢

  [pager]
  ignore = diff

and get diff totally without paging并完全获得差异而无需分页

  • From the other side (contrary to the above point), you can use --config从另一边(与上述观点相反),您可以使用--config

set/override config option (use 'section.name=value')设置/覆盖配置选项(使用'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调用hg diff的选项(当|如果您将 delta 作为工作寻呼机)并为简单起见为“hg diff with delta”创建 hg-alias,例如

  ddiff = diff --config pager.pager=delta $@

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM