up vote 0 down vote favorite
1
share [g+] share [fb]

I use various Linux programs on my Windows machine; some of them have colorized output. GnuWin32 and so forth.

However, Windows PowerShell does not support Linux colors; it gets a message like ←[0m31m(which is the color control code), and renders that instead of the color.

Is there any way around this?

link|improve this question

70% accept rate
feedback

4 Answers

up vote 2 down vote accepted

Powershell is just a text-mode program, running in the Windows console. The Windows console does not support ANSI escape sequences which is what you are seeing.

To fix it, it depends a lot on which program you are using. I am guessing you use cygwin to run these scripts?

link|improve this answer
In this instance, I was using a python program, mercurial. – Paul Nathan Dec 18 '09 at 19:03
I wish you had said Perl, then I would tell you about the Win32::Console module for Perl :) I am not sure what you can do to get colors with Windows-Python. – Kevin Panko Dec 18 '09 at 20:40
feedback

You can use Cygwin to run PowerShell and PowerShell scripts:

alt text

Cygwin can handle the escape sequences.

link|improve this answer
What if I don't want to use cygwin? – Paul Nathan Dec 18 '09 at 19:03
Then you can take any of the other suggestions here – Daniel Mar 29 '10 at 17:57
feedback

You could use a Linux virtual machine to launch these scripts. This is a big thing for a small result if it's just about showing colors, but it can't hurt to run the scripts on the platform they were made for.

link|improve this answer
yeah, that's too big to justify for this one thing. Plus I don't have a VM hypervisor running, and I do not want to install one. – Paul Nathan Dec 18 '09 at 16:49
feedback

You said you were using Mercurial to run the Linux programs. Assuming you're referring to the source control system (which I didn't realize could run Linux programs; I only use it for source control), there's an extension that will let you show color. Wincolor will intercept the ANSI color control and call the appropriate Windows functions. It seems to work no matter what, but I think it works better with pyreadline installed.

Note: I have treid this without pyreadline, and it didn't work for me. I have not yet tried it with pyreadline.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.