ANSI color support using Groovy on Windows XP

Try the examples found at pleac.sf.net , I cannot get an ANSI color example to work my WinXP box (works fine on macOS). I found that on my WinXP machine, the cygwin and DOS prompts (and 'groovysh --terminal = unix' ) show return codes rather than the expected colored prompt. works fine on cygwin terminal. I cannot find anything obvious that I am wrong. Any ideas? groovysh --color

grep --color

Note: I am using Groovy 1.6.0

Update: I tried to add ANSI.sys to my config.nt mentioned here by Groovy -dev mailing list , but that didn't fix the problem (also tried reloading).

0


a source to share


4 answers


The thing is, you need to add DOSONLY to your CONFIG.NT to get the ANSI.SYS driver to work, and then it will 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.

+1


a source


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

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

      

Then from the command shell



groovy.bat red.groovy | cat

      

the correct colors are displayed. Of course, you can write your own custom code that handles ANSI codes.

+3


a source


The Groovy site says to do this for cygwin:

groovysh --terminal=unix    

      

For the winxp shell, as far as I know, there is no ANSI support, even with ansi.sys. Colors are only supported using MS API.

0


a source


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

0


a source







All Articles