Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way to automatically make gcc color its output?

I am looking to avoid an alias as the the command is commonly used in makefiles (where it will not be used).

Is there an easy way to do this?

Note: this does require gcc/g++ 4.9, which is currently available via svn. I am willing to recompile if the change is something small (in a config file or something).

I know that the GCC_COLOR environment variable is used, but I am not sure how to set it, or what to set it to.

share|improve this question
up vote 4 down vote accepted

Add to your .bashrc:

export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'

But note that GCC 4.9 is under heavy development, so the defaults may change.

share|improve this answer
This did not work. Any ideas? – soandos Apr 24 '13 at 3:13
You need at least r198332. – Manuel López-Ibáñez May 2 '13 at 14:43

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.