Last Updated: February 25, 2016
·
752
· caioariede

Fast recursive code grepping

In almost all times that I use grep I use it to find peaces of code. I usually even know what kind of file I'm looking for. So I wrote this function that helps me on both zsh and bash:

function g! { grep -nr --exclude=.git --exclude=.hg --exclude=.svn --include="*.$1" "$2" ${3-"."} --colour; }

How it works?

g! py "some python method Im looking for"

or

g! py "some python method Im looking for" somedir

Why?

It's really fast to search and to type! Without any extra installation.

Improve

Improve it for your needs. Essencially the --exclude parameters.