Home

Awesome

The Silver Searcher for Windows

Specificities of this fork

This repository is a fork of Geoff Greer's The Silver Searcher for Unix, also known as 'ag'.

It is dedicated to building a well behaved version of ag.exe for Windows.
The original version can be built for Windows using MinGW, but it has several serious shortcomings that limit its usefulness for Windows users world-wide.
This version has the following improvements:

Versions of Windows supported:

Thanks to Krzysztof Kowalczyk who did the original Native Visual Studio Port. I've actually started from his August 2016 code, and kept improving it.

For instructions on how to build this code, and with what tools, see win32/README.md.

Jean-François Larvoire

Original introduction

A code searching tool similar to ack, 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?

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 ~/code 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?

I've written several blog posts showing how I've improved performance. These include how I added pthreads, wrote my own scandir(), benchmarked every revision to find performance regressions, and profiled with gprof and Valgrind.

Installing

macOS

brew install the_silver_searcher

or

port install the_silver_searcher

Linux

BSD

Windows

Building from source

Building master

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

    • macOS:

        brew install automake pkg-config pcre xz
      

      or

        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 with Visual C++:

        Nothing to do. All necessary libraries are provided in the [win32](win32/README.md) subdirectory.
      
    • Windows with MinGW:

        It's complicated. See [this wiki page](https://github.com/ggreer/the_silver_searcher/wiki/Windows).
      
  2. Run the build script (which just runs aclocal, automake, etc):

    • In all Unix versions:

      ./build.sh

    • On Windows (inside a cmd shell with Microsoft Visual C++, using this set of sources):

      win32\make.bat

    • On Windows (inside an msys/MinGW shell with gcc):

      make -f Makefile.w32

  3. Make install:

    • In all Unix versions, and Windows with MinGW:

      sudo make install

    • On Windows (inside a cmd shell with Microsoft Visual C++):

      The 32-bit and 64-bit version are in bin\WIN32\ag.exe and bin\WIN64\ag.exe respectively.

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:

./configure
make
make install

You may need to use sudo or run as root for the make install.

Editor Integration

Vim

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

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

or:

let g:ackprg = 'ag --vimgrep'

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

Emacs

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

TextMate

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