Question

Trying out the examples found on pleac.sf.net, I'm not able to get an example of ANSI colors to work on my WinXP box (Works fine on MacOS). What I've found is that on my WinXP machine, in both cygwin & DOS prompts, groovysh --color (and 'groovysh --terminal=unix') shows escape codes rather than the expected colored prompt. grep --color works just fine in the cygwin terminal. I can't find anything obvious that I'm doing wrong. Any ideas?

Note: I'm using Groovy 1.6.0

Update: I've tried adding ANSI.sys to my config.nt mentioned here Groovy-dev Mailing List but it didn't fix the problem (tried rebooting too).

Was it helpful?

Solution

The thing is, you'd have to add DOSONLY to your CONFIG.NT as well to make the ANSI.SYS driver work, and then it would only work for COMMAND.COM which emulates DOS 5.0. Regular Command Prompts (CMD.EXE) do not support ANSI colors at all, afaict.

I don't know much about how cygwin handles it.

OTHER TIPS

I have the same problem, my solution is ugly but simple: Pipe groovy output to cygwin cat.exe Suppose your script red.groovy is:

println "\u001B[31mI'm Red\u001B[0m Now not"

Then from command shell

groovy.bat red.groovy | cat

will display the right colors. Of course you can write your own native code that handle the ANSI codes.

The Groovy site says to do this for cygwin:

groovysh --terminal=unix    

For the winxp command shell, as far as I know, there is no ANSI support at all, not even with ansi.sys. Colors are supported through some MS API only.

A workaround in cygwin is to launch xterm or rxvt and run it there.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top