カレントディレクトリ以下の再帰検索をよく使うのだけど、打つのが面倒くさいのでエイリアス登録。
ackやagが入ってない環境のことも考えて・・・一応こっちも登録しておく。
bashなので、エイリアスというか関数で作る。
fgrepなのは、意外と正規表現を使わないから。それよりもレスポンスが速い方がいい。正規表現を使いたくなったら他のコマンドを使う。
# ~/.bashrcなどに追記。
# C/C++用
function grepc() {
LANG=C fgrep --color -Inr \
--exclude-dir='.git' \
--exclude-dir='.svn' \
--include='*.h' \
--include='*.hpp' \
--include='*.m' \
--include='*.c' \
--include='*.cc' \
--include='*.cpp' \
"$1" .
}
# header only
function greph() {
LANG=C fgrep --color -Inr \
--exclude-dir='.git' \
--exclude-dir='.svn' \
--include='*.h' \
--include='*.hpp' \
"$1" .
}
# Webっぽい言語用
function grepw() {
LANG=C fgrep --color -Inr \
--exclude-dir='.git' \
--exclude-dir='.svn' \
--exclude-dir='node_modules' \
--exclude-dir='vendor' \
--exclude='*.min.js' \
--exclude='*.min.css' \
--include='*.js' \
--include='*.ejs' \
--include='*.css' \
--include='*.scss' \
--include='*.html' \
--include='*.php' \
--include='*.sql' \
--include='*.rb' \
--include='*.pl' \
--include='*.py' \
"$1" .
}