Created
February 3, 2011 09:56
-
-
Save gorenje/809293 to your computer and use it in GitHub Desktop.
find-rails bash alias
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function _funct_find_rails | |
{ | |
local app="" | |
local option= | |
local what=$* | |
OPTIND=1 | |
while getopts "a:es:" option | |
do | |
case $option in | |
e) | |
app="Emacs" | |
;; | |
a) | |
app=$OPTARG | |
;; | |
s) | |
what=$OPTARG | |
;; | |
esac | |
done | |
local open_string="" | |
if [ "$app" != "" ] ; then | |
open_string="-exec open -a ${app} {} \\;" | |
fi | |
for n in rjs rb erb haml rake rhtml yml gemspec; do | |
echo -e "\033[01;36m####### Searching all ${n} files ##########\033[01;00m" | |
gfind . -type f -name \*.${n} -exec grep -i --color "${what}" {} \; -printf "\033[01;33m%p\033[01;00m\\n" ${open_string} | |
done | |
for n in Rakefile Capfile ; do | |
echo -e "\033[01;36m####### Searching all ${n} files ##########\033[01;00m" | |
gfind . -type f -name ${n} -exec grep -i --color "${what}" {} \; -printf "\033[01;33m%p\033[01;00m\\n" ${open_string} | |
done | |
for n in readme ; do | |
echo -e "\033[01;36m####### Searching all ${n} files ##########\033[01;00m" | |
gfind . -type f -iname ${n}\* -exec grep -i --color "${what}" {} \; -printf "\033[01;33m%p\033[01;00m\\n" ${open_string} | |
done | |
echo -e "\033[01;36m####### Searching in all script directories ##########\033[01;00m" | |
for dirname in `find . -type d -name script -print` ; do | |
echo "# ${dirname}" | |
gfind $dirname -type f -exec grep -i --color "${what}" {} \; -printf "\033[01;33m%p\033[01;00m\\n" ${open_string} | |
done | |
} | |
alias find-rails=_funct_find_rails |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment