I was triggered by this post on ReadWriteWeb to write a small bash script to make it easy for me to use grep to look for a pattern in my source code.
The post on ReadWriteWeb points to the -i -r -E -n -C –colors options to make grep recursively and case insensitively search for a pattern and displays the result with colors. I wanted to make it easy for me to use all these by doing search . “->foo\(“ for example.
First, I created the following search.sh script and made it executable
grep -inIEr --color=ALWAYS $2 -C1 $1
Then, I edited my .bash_profile file and added
Then, I reloaded my profile by doing source .bash_profile and tested my search function
search . "->load\->"
Nothing complicated but it’s pretty handy