I want to use customized template for hg log which looks like this:
hg log --template '{node|short} {desc} [{date|age} by {author}]\'n --color=always
This in default terminal color is not very readable, so for instance I would like to make node red and desc green. How can I do this? In git I can define this kind of formatting like this:
git log --pretty=format:'%Cred%h%Creset %Cgreen%s%Creset [%ar by %an]'
Is a similar thing possible in mercurial?
AFAIK, there’s no way to do this directly in Mercurial, but if you’re on a Unix-y system you could use ANSI escape codes to control the colors. For example:
will give you the
nodein red and thedescin green.On the Windows command prompt, you have to enable the ColorExtension and the codes are the parameters to the color command (
help colorin the command prompt), so the equivalent would be:Note: in the second escape sequence, the
0is to reset the text color and the2is to set it to green. Without the0, it seems you get an inclusive-or of the color codes, which in this case would be yellow.