To search for a string found in files in your current working directory you might use grep like so:

grep -r foo .  

But this command searches every subdirectory which can produce false positives among results found in third party code or temporary files.

In this case, leverage the power of the find command in conjunction with grep to ignore common directories that don’t pertain to most projects.

Add this to your ~/.bashrc:

findterm() {  
  find . -type f \! -path "*.DS_Store*" \! -path "*tmp*" \! -path "*.sass-cache*" \! -path "*dist*" \! -path "*node_modules*" \! -path "*bower_components*" \! -path "*.git*" -print -exec grep $SEARCHTERM {} \;

Search for foo with:

findterm foo  

Notice every filename will be printed even if no results are found. If a result is found it will be printed on a separate line beneath the filename.