I'm compiling a file with gcc (actually I'm make'ing, but never mind), which sends some colorized error messages to stderr. So, I do:
gcc a.c 2>&1 | less
but what I get is lines such as:
a.c: In function <E2><80><98>whatever(int)<E2><80><99>:
a.c:11:10: warning: etc etc
that is, I see the numeric escape codes rather than the colors.
I tried to follow the advice in this answer on SU, but it didn't work for me. Or rather, ls --color | less
works, but not my gcc command above. What should I do?
Notes:
- I'm connected to this machine via SSH, with
TERM=xterm-256color
- Without piping through
less
, I do get the colors on the terminal.
less -R
work?cat
? Do you still see colors on the terminal?cat -v
I notice there are nonprinting characters.gcc
is generating when its output is sent somewhere other than a tty—rather than a problem withless
. I don't have agcc
man page on the box I'm on right now, but if you search for "color" in your man page you might find something. Good luck. :)