Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

I recently found that on Mac OS X I can set this up in my shell ~/.profile so that when I use grep it will print the matches in color (white one red).

alias grep='GREP_COLOR="1;37;41" LANG=C grep --color=auto'

But setting up an alias seems like kind of a hack way to do this. Previously I had tried with no luck:

export GREP_COLOR=always           # works fine in Linux

And then I also tried:

export GREP_COLOR="1;37;41"

Is there a better way to do this than setting up an alias?

share|improve this question
I don't see the point of your question. An alias is how you do this. That's what it's for. export the environment variable e.g. in .bash_profile, and define alias grep='grep --color', and you're done. – Daniel Beck Apr 25 '12 at 18:05
up vote 27 down vote accepted

Per Grep_color on mac as suggested by @lupincho, this seems to work fine and does not use an alias:

export GREP_OPTIONS='--color=always'
export GREP_COLOR='1;35;40'
share|improve this answer
Didn't work for me. :( – trusktr Nov 25 '14 at 23:04
Did you restart your terminal ? – Mike Nguyen Jul 16 '15 at 8:31
Have a +1 for this as a good solution, however setting GREP_OPTIONS leads to grep: warning: GREP_OPTIONS is deprecated; please use an alias or script. Something like this is now preferred: alias grep="`which grep` --color=always" – joelittlejohn Nov 6 '15 at 12:06

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.