views:

22

answers:

1

I'm using cucumber to run some tests. It colorizes its output using ANSI escapes. This is great, but currently its producing more output than I care about, and shoving things I do care about off the screen. There doesn't seem to be a way to eliminate the other lines from within cucumber, but I can pipe the output through grep to pare down to the ones I care about.

The downside of this solution, though, is that all the colors are lost. I know it's not my shell or grep's fault, because % echo "\e[35mhello\e[00m world" | grep hello works just fine, so it must be cucumber disabling its own color somehow.

How can I preserve the colored output when I pipe the output of cucumber?

+1  A: 

Doh. It's covered in cucumber -h. Use the -c flag to force colorized output.

rampion
A lot of programs which produced colorized output often only do so when stdout is a terminal -- if stdout is a pipe, they will not use color.
Adam Rosenfield
True. `ls --color=auto` and `grep --color=auto` are two examples.
Dennis Williamson