[Tipz] colorize your grep

Adam Katz katz+tipz at ccs.neu.edu
Thu Feb 12 15:21:27 EST 2004


you can color your search terms
with grep --color
or do it automatically as follows:

you should put the following in .bashrc or wherever:
   GREP_OPTIONS='--color=auto'
   GREP_COLOR='5;38'
   export GREP_OPTIONS GREP_COLOR
this will colorize your search query (only) as underlined or w/ gray bg

color codes are just like your bash prompt.
default color is '0;31'
you can play with color codes like this:
   echo -e '\033[0;31mtest'
   (this will say "test" in red)

this is all in grep's man page at the end,
in the ENVIRONMENT VARIABLES section.

-adam



More information about the Tipz mailing list