Take the 2-minute tour ×

When running command-line Mercurial with the color extension on, the colors appear as expected in the Windows command prompt (cmd.exe). However, in cygwin the colors are appearing as the underlying ANSI codes (for example: ←[0;34;1m).

When I searched for a solution, it seemed it's more common for colors to work in cygwin but not in command prompt. Have I forgotten to install something useful in cygwin that would activate display of colors?

I experience the problem on both a Windows 7 64-bit and a Vista 32-bit machine. I've tried both bash and tcsh shells. I can see colors in both shells if I do something like ls --color.

share|improve this question
add comment

2 Answers

up vote 4 down vote accepted

When you use the Cygwin console, the interpretation of control sequences is done by the Cygwin DLL. That DLL of course is only linked into Cygwin programs, so a non-Cygwin program like Mercurial will not be able to make use of that.

So why does it work when running in a cmd.exe console then, which doesn't understand control sequences in the first place? My guess would be that Mercurial uses the Windows console API when it thinks it runs in a console, and control sequences when it thinks it's running in a terminal. Perhaps that depends on whether TERM is set, so try what happens if you unset TERM.

Otherwise, try running it in a Cygwin terminal such as mintty or rxvt. There, the difference is that the control sequences are interpreted by those programs rather than the Cygwin DLL.

share|improve this answer
Thanks ak2. Unsetting TERM did the trick. –  Ash Sep 9 '10 at 13:11
add comment

In your .hgrc file set

mode = ansi


mode = auto
share|improve this answer
Thanks Dennis, I tried both but no luck. –  Ash Sep 9 '10 at 13:10
'mode = win32' would be the right setting there, me thinks, to tell it to use the Windows console API rather than the ANSI sequences. –  ak2 Sep 9 '10 at 14:56
Yep, that works too –  Ash Sep 9 '10 at 21:54
add comment

Your Answer


