A wrapper (Perl script) to colorize the output of gcc
/g++
compilers.
- Version: 1.4.4
- Original author: Jamie Moyers
- Recent maintainer and contributors: olibre , Nikita Malyavin (FooBarrior) , Juan Batiz-Benet , Steven Honeyman , Johannes Schlüter , Zuyi Hu , Adam Nielsen (Malvineous) , Karl Fessel , James E. Flemer
- Earlier contributors: Adrian Likins , Scott Harrington , Elias S. G. Carotti , Erwin S. Andreasen , Steve Churchill , Rik Hemsley
- Started: April 20, 1999
- GNU General Public License v2 (see file
LICENSE
)
- A terminal that groks color escape sequences
- Perl module ANSIColor.pm (available at www.cpan.org)
- Perl modules Open3, Basename, Spec and Cwd
Copy colorgcc
in a directory of your choice (e.g. ~/bin
).
Then create symlinks pointing to colorgcc
. There are two options described above.
The directory where these links are created must be placed in $PATH
before the directory where the compiler lives.
Create a link to colorgcc
for each compiler you want to colorize:
> ls
colorgcc
> ln -sv colorgcc gcc; ln -sv colorgcc g++; ln -sv colorgcc cc; ln -sv colorgcc c++;
gcc -> colorgcc
g++ -> colorgcc
cc -> colorgcc
c++ -> colorgcc
> PATH="$(pwd):$PATH"
When g++
is invoked, colorgcc
is run instead and looks at the program name to figure out which compiler to run.
The right compiler is then searched within the rest of the $PATH
.
Create links to colorgcc
using composed filenames:
color-g++ -> colorgcc
color-c++ -> colorgcc
color-gcc -> colorgcc
color-cc -> colorgcc
Then override the compiler macros for make
:
make CXX=color-g++ CC=color-gcc
The default settings can be overridden with ~/.colorgccrc
.
See the comments in the sample .colorgccrc
for more information.
colorgcc
will only emit color codes if:
- Its STDOUT is a tty and
- the value of $TERM is not listed in the "nocolor" option.
If colorgcc
colorizes the output, the compiler's STDERR will be
combined with STDOUT. Otherwise, colorgcc
just passes the output from
the compiler through without modification.
Packages that use autoconf
(./configure
) apparently determine
the default location of $prefix
from the location of gcc
.
If you create the links as recommended above, $prefix
will become
that directory instead of what it should be (/usr/local
for
example).
It's easy to get around this by giving an explicit --prefix=/usr/local
when you configure a package, but it's a minor annoyance.