LoginSignup
55
53

More than 5 years have passed since last update.

the silver searcherのファイル指定オプション

Last updated at Posted at 2014-05-29

the silver searcher とは

grepをより高速かつ今時のファイル検索にむいたUIにしたackを
使い勝手はそのままに、更に高速に!と欲張ってみた文字列検索コマンドです。

Macだと

$ brew update
$ brew install the_silver_searcher

でさくっと入ります。

the_silver_searcher - Github

特徴

  • ackの3〜5倍は速いらしい
  • .gitignore .hgignore で指定されたファイルは検索対象にしない
  • silverサーチ……銀……Ag。というわけで、コマンドはagです。タイプしやすい!

使い方

$ ag regexp app  # appディレクトリ以下のファイルからregexpに一致する文字列検索
$ ag -i regexp   # 大文字小文字を無視
$ ag rails Gemfile*  # Gemfile Gemfile.lock などのファイルからrailsを検索

ファイル指定

いままでずっと

$ ag foo -G \.rb$$

とやっていたんですが

$ ag --ruby foo  # .rb .rhtml .rjs .rxml .erb .rake .specのみ検索
$ ag --list-file-types # 指定できるファイル一覧

と指定できると知りました。
自分用によく使うファイル種類と対象拡張子をメモ。

option extension
--cc .c .h .xs
--cpp .cpp .cc .cxx .m .hpp .hh .h .hxx
--go .go
--rake Rakefiles
--ruby .rb .rhtml .rjs .rxml .erb .rake .spec
--shell .sh .bash .csh .tcsh .ksh .zsh
--smalltalk .st
--sql .sql .ctl
Asset系
--css .css
--sass .sass .scss
--coffee .coffee
--js .js
データ系
--haml .haml
--html .htm .html .shtml .xhtml
--json .json
--xml .xml .dtd .xsl .xslt .ent
--yaml .yaml .yml

おともだち

silver searchはutf-8前提で文字列検索をします。
なのでShift-JIS等の検索をしたい場合は
the platinum searcher - Github
を使わせてもらいましょう。

the mithril searcherはまだありません。

55
53
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
55
53