In Git Bash on Windows 7, I occasionally have something happen that causes the color coding to fail when running cucumber scenarios or rspec specs.
Occasionally, it
Try installing the win32console gem.
gem install win32console
After a number of fruitless attempts to get some colors on my Windows 7 bash terminals (msysgit with console2), I stumbled on Jason Karns blog 'ANSI color in Windows Shells'.
All I had to do was unzip ansicon.exe to a permanent folder and run via cmd in that folder:
ansicon.exe -i
All bash logs now have colors instead of the [32m or [0m tags, woo!
I fixed this with Git For Windows (V2.5.3) running Git within PowerShell (in Window's normal console) by setting three environment variables:
TERM=msys
PAGER='"C:\Program Files\Git\usr\bin\less.exe"'
(note the double quotes need to be part of the value).--RAW-CONTROL-CHARS
in LESS
s value (so with my other preferences: --LONG-PROMPT --no-init --quit-if-one-screen --RAW-CONTROL-CHARS
).On windows, git Bash uses the built in terminal which is rolled into the cmd prompt. If you install cygwin you can use the mintty terminal emulator (Installed on the start menu as "Cygwin Terminal").
Why is this important? Because the windows cmd prompt term does not interpret ANSI escape sequences. It uses M$ color control scheme instead. If the program you are using does not switch to this scheme on windows, or go through a filter, then you will see the raw escape characters. Cygwin's mintty console has full support for these codes.
If the colors usually work, this is a bug in cucumber/rspec from porting. Somebody missed a check for windows when printing the colors or something. Until this gets fixed, a work around is the following python script:
#!/usr/bin/env python
# Filter ANSI escapes from stdin to stdout
from __future__ import print_function
from colorama import init
import sys
init()
for line in sys.stdin.readlines():
print(line)
You will need to install the colorama library for this. Then just pipe your output through the script:
$ bundle exec rspec spec | colorFilter.py
I have had the same pb, it seems that if you unset the TERM environment variable it works again.
I use @aslakhellesoy's "wac" project. It's a little annoying because you have to remember to pipe your commands through it. But it's the only thing I've seen work.
https://github.com/aslakhellesoy/wac