Mercurial color extension in Windows Powershell
Is there a way to enable color support for Mercurial in Powershell on Windows 7? The ColorExtension page says to add
[color]
mode = win32
to your .hgrc
file, but it doesn't seem to make a difference.
Running hg status
shows several files that have not yet been added to the repository, and I believe they should have a pink color (based off other terminals I've seen). This is what's displayed instead:
←[0;35;1;4m? samplefile.php←[0开发者_StackOverflow中文版m
←[0;35;1;4m? anotherfile.php←[0m
←[0;35;1;4m? derpderp.xml←[0m
←[0;35;1;4m? derp_model.php←[0m
←[0;35;1;4m? stillnocolor.php←[0m
You probably need to update to the latest mercurial (1.6.4). Version 1.5.4 in particular didn't do win32 color properly (and there have been quite a few color-related and win32-related bugs fixed in recent builds).
You also need to make sure you're not specifying ANSI color mode. You can force win32:
[color]
mode = win32
Did you also make sure to enable the ColorExtension? You need this in your .hgrc too:
[extensions]
color =
If that's there too you can make sure your settings are being picked up with:
hg --debug showconfig
ColorExtension
does not work in PowerShell as of version 2.8, see https://www.mercurial-scm.org/pipermail/mercurial-devel/2013-November/054620.html:
When using Windows PowerShell color doesn't work (although it works perfectly fine with
cmd.exe
).Looks like although being called,
_kernel32.SetConsoleTextAttribute
has no effect when running within PowerShell.
This is Mercurial bug 4093 which has been resolved as "won't fix". One workaround is to use ansicon. See this answer for more information.
精彩评论