How to use LC_MESSAGES=C with gcc every time?

Posted on

Problem :

Currently I’m using Ubuntu with my system locale and language set to Japanese. However I’d like to have it always displaying gcc messages in English as it would be easier for me.

I found here if I did ~$ LC_MESSAGES=C gcc it displays in English. How can I make it so it’s always like this without entering in ~$ LC_MESSAGES=C gcc every time and without changing my system language? All I want changed is “gcc”.

Solution :

Create an alias in your shell.

alias gcc="LC_MESSAGES=C gcc"

The trouble with an alias will be that they don’t transfer to things like make very reliably. If I needed to do it, I’d probably create a shell script called gcc in my $HOME/bin directory which would set the environment variable and execute the ‘real’ gcc. My own bin directory is always on my PATH ahead of system directories. Hence:

LC_MESSAGES=C exec /usr/gcc/v4.7.1/bin/gcc "$@"

Try setting LC_MESSAGES=C in your users ~/.profile

export LC_MESSAGES=C

EDIT
Yeah don’t use that it will change LC_MESSAES locale for all applications under your user that use it. Credit to Ignacio Vazquez-Abrams

Leave a Reply

Your email address will not be published. Required fields are marked *