我想使用定制模板hg log
看起来像这样:
hg log --template '{node|short} {desc} [{date|age} by {author}]\'n --color=always
默认终端颜色的可读性不太好,所以例如我想将节点设为红色,将 desc 设为绿色。我怎样才能做到这一点?在 git 中我可以像这样定义这种格式:
git log --pretty=format:'%Cred%h%Creset %Cgreen%s%Creset [%ar by %an]'
Mercurial 中可能有类似的事情吗?
截至 2013 年,Mercurial 直接支持模板上的颜色。您还可以检查hg 帮助模板.
您必须激活您的颜色扩展.hgrc:
[extensions]
color =
然后添加一些稍后在模板上使用的自定义标签:
[color]
custom.rev = yellow
custom.author = bold
然后使用引用标签的模板(使用{标签('标签名称',字段)}代替{field}:
hg log --template "{label('custom.rev',node|short)} {desc} [{date|age} by {label('custom.author',author)}]\n"
上面的示例以黄色突出显示节点(修订版),以粗体蓝色突出显示提交的作者。与往常一样,您可以在 .hgrc 上创建别名:
[alias]
customlog = log --template "{label('custom.rev',node|short)} {desc} [{date|age} by {label('custom.author',author)}]\n"
Update:测试版本2.5.4。
根据变更日志, this 作品
从2.5版本开始.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)