Pretty Recursive Grep
TL;DR Set GREP_OPTIONS='-RI --color=auto'
. Or install ack.
I’m looking for TODO entries in source code on a machine that does not have ack installed. It does have GNU grep, though.
Obviously I want to search subdirectories. I can choose between
--recursive
, -R
, or using rgrep
on this particular machine.
I am usually searching through source code. I hardly ever want
binary files to match. That means --binary-file=without-match
or -I
.
Finally, I like pretty colors. The --color=auto
option makes me
happy.
That leaves me with this invocation.
$ grep --recursive --binary-file=without-match --color=auto 'TODO' .
Or maybe the short form would be easier.
$ rgrep -I --color=auto 'TODO' .
Probably smartest to look at what environment variables I could set up in order to skip remembering this stuff at all.
export GREP_OPTIONS='-RI --color=auto'
Pop that in my .bashrc
and I’m set.
$ grep 'TODO' .
All right. Back to work.