Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
add comment

5 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?

share|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
add comment

You can use Cygwin to run PowerShell and PowerShell scripts:

alt text

Cygwin can handle the escape sequences.

share|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 H Mar 29 '10 at 17:57
add comment

For posterity

You can use ANSICON to display ANSI escape sequences in Windows consoles, including Powershell. This should give you color.

This issue thread on getting it to work with PowerShell has a few different solutions as there is more than one way to do it.

share|improve this answer
add comment

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.

share|improve this answer
add comment

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.

share|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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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