LoginSignup
4
4

More than 5 years have passed since last update.

個人的grepのエイリアス

Last updated at Posted at 2015-09-11

カレントディレクトリ以下の再帰検索をよく使うのだけど、打つのが面倒くさいのでエイリアス登録。
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" .
}
4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4