Need help with the_silver_searcher?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

22.7K Stars 1.3K Forks Apache License 2.0 2.1K Commits 504 Opened issues


A code-searching tool similar to ack, but faster.

Services available


Need anything else?

Contributors list

The Silver Searcher

A code searching tool similar to

, with a focus on speed.

Build Status

Floobits Status

#ag on Freenode

Do you know C? Want to improve ag? I invite you to pair with me.

What's so great about Ag?

  • It is an order of magnitude faster than
  • It ignores file patterns from your
  • If there are files in your source repo you don't want to search, just add their patterns to a
    file. (*cough*
  • The command name is 33% shorter than
    , and all keys are on the home row!

Ag is quite stable now. Most changes are new features, minor bug fixes, or performance improvements. It's much faster than Ack in my benchmarks:

ack test_blah ~/code/  104.66s user 4.82s system 99% cpu 1:50.03 total

ag test_blah ~/code/ 4.67s user 4.58s system 286% cpu 3.227 total

Ack and Ag found the same results, but Ag was 34x faster (3.2 seconds vs 110 seconds). My

directory is about 8GB. Thanks to git/hg/ignore, Ag only searched 700MB of that.

There are also graphs of performance across releases.

How is it so fast?

  • Ag uses Pthreads to take advantage of multiple CPU cores and search files in parallel.
  • Files are
    ed instead of read into a buffer.
  • Literal string searching uses Boyer-Moore strstr.
  • Regex searching uses PCRE's JIT compiler (if Ag is built with PCRE >=8.21).
  • Ag calls
    before executing the same regex on every file.
  • Instead of calling
    on every pattern in your ignore files, non-regex patterns are loaded into arrays and binary searched.

I've written several blog posts showing how I've improved performance. These include how I added pthreads, wrote my own

, benchmarked every revision to find performance regressions, and profiled with gprof and Valgrind.



brew install the_silver_searcher


port install the_silver_searcher


  • Ubuntu >= 13.10 (Saucy) or Debian >= 8 (Jessie)

    apt-get install silversearcher-ag
  • Fedora 21 and lower

    yum install the_silver_searcher
  • Fedora 22+

    dnf install the_silver_searcher
  • RHEL7+

    yum install epel-release.noarch the_silver_searcher
  • Gentoo

    emerge -a sys-apps/the_silver_searcher
  • Arch

    pacman -S the_silver_searcher
  • Slackware

    sbopkg -i the_silver_searcher
  • openSUSE

    zypper install the_silver_searcher
  • CentOS

    yum install the_silver_searcher
  • NixOS/Nix/Nixpkgs

    nix-env -iA silver-searcher
  • SUSE Linux Enterprise: Follow these simple instructions.


  • FreeBSD

    pkg install the_silver_searcher
  • OpenBSD/NetBSD

    pkg_add the_silver_searcher


  • Win32/64

Unofficial daily builds are available.

  • winget

    winget install "The Silver Searcher"

Notes: - This installs a release of ag.exe optimized for Windows. - winget is intended to become the default package manager client for Windows.
As of June 2020, it's still in beta, and can be installed using instructions there. - The setup script in the Ag's winget package installs ag.exe in the first directory that matches one of these criteria: 1. Over a previous instance of ag.exe from the same origin found in the PATH 2. In the directory defined in environment variable bindir%PROCESSORARCHITECTURE% 3. In the directory defined in environment variable bindir 4. In the directory defined in environment variable windir

  • Chocolatey

    choco install ag
  • MSYS2

    pacman -S mingw-w64-{i686,x86_64}-ag
  • Cygwin

Run the relevant

, and select "the_silver_searcher" in the "Utils" category.

Building from source

Building master

  1. Install dependencies (Automake, pkg-config, PCRE, LZMA):

    • macOS:

      brew install automake pkg-config pcre xz


      port install automake pkgconfig pcre xz
    • Ubuntu/Debian:

      apt-get install -y automake pkg-config libpcre3-dev zlib1g-dev liblzma-dev
    • Fedora:

      yum -y install pkgconfig automake gcc zlib-devel pcre-devel xz-devel
    • CentOS:

      yum -y groupinstall "Development Tools"
      yum -y install pcre-devel xz-devel zlib-devel
    • openSUSE:

      zypper source-install --build-deps-only the_silver_searcher
* Windows: It's complicated. See [this wiki page](
  1. Run the build script (which just runs aclocal, automake, etc):


On Windows (inside an msys/MinGW shell):

    make -f Makefile.w32
  1. Make install:

    sudo make install

Building a release tarball

GPG-signed releases are available here.

Building release tarballs requires the same dependencies, except for automake and pkg-config. Once you've installed the dependencies, just run:

make install

You may need to use

or run as root for the make install.

Editor Integration


You can use Ag with ack.vim by adding the following line to your

let g:ackprg = 'ag --nogroup --nocolor --column'


let g:ackprg = 'ag --vimgrep'

Which has the same effect but will report every match on the line.


You can use ag.el as an Emacs front-end to Ag. See also: helm-ag.


TextMate users can use Ag with my fork of the popular AckMate plugin, which lets you use both Ack and Ag for searching. If you already have AckMate you just want to replace Ack with Ag, 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"

Other stuff you might like

  • Ack - Better than grep. Without Ack, Ag would not exist.
  • ack.vim
  • Exuberant Ctags - Faster than Ag, but it builds an index beforehand. Good for really big codebases.
  • Git-grep - As fast as Ag but only works on git repos.
  • fzf - A command-line fuzzy finder
  • ripgrep
  • Sack - A utility that wraps Ack and Ag. It removes a lot of repetition from searching and opening matching files.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.