The Silver Searcher
An attempt to make something better than ack, which itself is better than grep.
Why use ag?
- It searches through code about 3x-5x faster than ack.
- It ignores files matched by patterns in your .gitignore and .hgignore.
- If there are files in your source repo that you don't want to search, just add their patterns to a .agignore file. *cough* extern *cough*
- It's written in C instead of perl, the lesser of two evils :)
- The binary name is 33% shorter than ack!
sudo add-apt-repository ppa:ggreer/ag sudo apt-get install the-silver-searcher
brew install pcre pkg-config
Then build from source. Once Ag becomes more popular, hopefully someone will submit a pull request to homebrew.
For debs, rpms, and static builds, see the downloads page.
Building from source
- Install PCRE development libraries:
- Run the build script (which just runs aclocal, automake, etc):
- Make install:
sudo make install
Current development status
On the continuum of...
- Behaves correctly
- Behaves correctly and runs fast
...it's somewhere between 2 and 3 right now. Although it's much faster than ack in my benchmarks.
ack -i SOLR ~/cloudkick/reach 2.89s user 0.77s system 97% cpu 3.765 total ag -i SOLR ~/cloudkick/reach 0.25s user 0.13s system 94% cpu 0.404 total
You can use this with my fork of the popular ackmate plugin, which lets you use both ack and ag for searching in Textmate. You can also move or delete
"~/Library/Application Support/TextMate/PlugIns/AckMate.tmplugin/Contents/Resources/ackmate_ack" and run
ln -s /usr/local/bin/ag "~/Library/Application Support/TextMate/PlugIns/AckMate.tmplugin/Contents/Resources/ackmate_ack"
- behave better when matching in files with really long lines
- maybe say "match found at position X of line N" if line is > 10k chars
- pthreads. these days it's silly to use only one core
- actually get textmate dir patterns working (this requires ruby regexes. not fun)