7
1
I would like to keep color in less command after using "make 2>&1" to compile some program. There are similar topics with "grep" and "ls" commands but solutions do not work with this command.
For instance,
make 2>&1 | less -R
does not work.
Thanks for your help.
This is a first step to a solution. The makefile contains gcc command and the option "-fdiagnostics-color" is necessary to keep color after gcc and pipe. Nevertheless, color is not kept after make and pipe. Even if I use a simple Makefile with only one "gcc" command inside and nothing else. – fylou – 2015-11-04T16:44:34.200
OK I understand the problem. Your solution works partially. Your CFLAGS can be overriden by any makefile. What I would like is to use a shell alias in the makefile. alias g++="g++ -fdiagnostics-color=always" is not enough or to know a cleaner solution. – fylou – 2015-11-04T17:09:10.797
A partial solution is to use make -e which keep variables taken from the environment precedence over variables from makefiles. It is not convenient in my case. – fylou – 2015-11-04T17:20:07.260
Did you try lowercase option
-r
forless
? – SΛLVΘ – 2015-11-04T19:33:25.827@fylou Why is the alias not a good enough solution for you? It looks like anything else will be a worse hack then this. – cristi – 2015-11-04T20:58:01.373
less -r doesn't not work.Aliases are not taken into account in the makefile. It would be ok for me if I could change this behaviour. – fylou – 2015-11-05T08:21:07.083
Assume that make output is colorized when not piped, on other commands (grep, ls, etcl) you add --colour=always (vs default auto). Make doesn't have this option so ? – Gerry Gleason – 2017-04-23T00:02:56.547