{"id":13392714,"url":"https://github.com/ggreer/the_silver_searcher","last_synced_at":"2025-05-11T05:46:14.893Z","repository":{"id":1884683,"uuid":"2810455","full_name":"ggreer/the_silver_searcher","owner":"ggreer","description":"A code-searching tool similar to ack, but faster.","archived":false,"fork":false,"pushed_at":"2024-06-16T19:37:41.000Z","size":2426,"stargazers_count":26540,"open_issues_count":561,"forks_count":1431,"subscribers_count":424,"default_branch":"master","last_synced_at":"2025-05-11T05:46:09.529Z","etag":null,"topics":["ag","c","command-line-tool","pcre","search-in-text","silver-searcher"],"latest_commit_sha":null,"homepage":"http://geoff.greer.fm/ag/","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ggreer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2011-11-19T19:50:47.000Z","updated_at":"2025-05-10T14:58:25.000Z","dependencies_parsed_at":"2023-07-05T20:02:41.152Z","dependency_job_id":"c0dd66f2-5c75-4a61-9ffc-6b65806ddb73","html_url":"https://github.com/ggreer/the_silver_searcher","commit_stats":{"total_commits":1602,"total_committers":246,"mean_commits":6.512195121951219,"dds":0.367665418227216,"last_synced_commit":"a61f1780b64266587e7bc30f0f5f71c6cca97c0f"},"previous_names":[],"tags_count":49,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ggreer%2Fthe_silver_searcher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ggreer%2Fthe_silver_searcher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ggreer%2Fthe_silver_searcher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ggreer%2Fthe_silver_searcher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ggreer","download_url":"https://codeload.github.com/ggreer/the_silver_searcher/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253523719,"owners_count":21921818,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ag","c","command-line-tool","pcre","search-in-text","silver-searcher"],"created_at":"2024-07-30T17:00:35.712Z","updated_at":"2025-05-11T05:46:14.870Z","avatar_url":"https://github.com/ggreer.png","language":"C","funding_links":[],"categories":["C","Text","Tools and Plugins","Development","Command-Line Productivity","tools","Command Line Utilities","User Interaction","Uncategorized","c","grep","Interaction","Containers \u0026 Language Extentions \u0026 Linting","Alternatives to `grep`","Development Environment","其他","Tools","Command Line","Other","Developer Tools","\u003ca name=\"text-search\"\u003e\u003c/a\u003eText search (alternatives to grep)","Grep Replacement","开发者工具","编程","What's in it?","Mac 软件"],"sub_categories":["Visual Studio Code","Windows","Time Series","Tools","Command Line Interface","Uncategorized","ag","Command Line","For JavaScript","网络服务_其他","C","Others","Command Line Tools","Open USP Tsukubai","命令行工具","Both platforms","命令行","Writing"],"readme":"# The Silver Searcher\n\nA code searching tool similar to `ack`, with a focus on speed.\n\n[![Build Status](https://travis-ci.org/ggreer/the_silver_searcher.svg?branch=master)](https://travis-ci.org/ggreer/the_silver_searcher)\n\n[![Floobits Status](https://floobits.com/ggreer/ag.svg)](https://floobits.com/ggreer/ag/redirect)\n\n[![#ag on Freenode](https://img.shields.io/badge/Freenode-%23ag-brightgreen.svg)](https://webchat.freenode.net/?channels=ag)\n\nDo you know C? Want to improve ag? [I invite you to pair with me](http://geoff.greer.fm/2014/10/13/help-me-get-to-ag-10/).\n\n\n## What's so great about Ag?\n\n* It is an order of magnitude faster than `ack`.\n* It ignores file patterns from your `.gitignore` and `.hgignore`.\n* If there are files in your source repo you don't want to search, just add their patterns to a `.ignore` file. (\\*cough\\* `*.min.js` \\*cough\\*)\n* The command name is 33% shorter than `ack`, and all keys are on the home row!\n\nAg is quite stable now. Most changes are new features, minor bug fixes, or performance improvements. It's much faster than Ack in my benchmarks:\n\n    ack test_blah ~/code/  104.66s user 4.82s system 99% cpu 1:50.03 total\n\n    ag test_blah ~/code/  4.67s user 4.58s system 286% cpu 3.227 total\n\nAck 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.\n\nThere are also [graphs of performance across releases](http://geoff.greer.fm/ag/speed/).\n\n## How is it so fast?\n\n* Ag uses [Pthreads](https://en.wikipedia.org/wiki/POSIX_Threads) to take advantage of multiple CPU cores and search files in parallel.\n* Files are `mmap()`ed instead of read into a buffer.\n* Literal string searching uses [Boyer-Moore strstr](https://en.wikipedia.org/wiki/Boyer%E2%80%93Moore_string_search_algorithm).\n* Regex searching uses [PCRE's JIT compiler](http://sljit.sourceforge.net/pcre.html) (if Ag is built with PCRE \u003e=8.21).\n* Ag calls `pcre_study()` before executing the same regex on every file.\n* Instead of calling `fnmatch()` on every pattern in your ignore files, non-regex patterns are loaded into arrays and binary searched.\n\nI've written several blog posts showing how I've improved performance. These include how I [added pthreads](http://geoff.greer.fm/2012/09/07/the-silver-searcher-adding-pthreads/), [wrote my own `scandir()`](http://geoff.greer.fm/2012/09/03/profiling-ag-writing-my-own-scandir/), [benchmarked every revision to find performance regressions](http://geoff.greer.fm/2012/08/25/the-silver-searcher-benchmarking-revisions/), and profiled with [gprof](http://geoff.greer.fm/2012/02/08/profiling-with-gprof/) and [Valgrind](http://geoff.greer.fm/2012/01/23/making-programs-faster-profiling/).\n\n\n## Installing\n\n### macOS\n\n    brew install the_silver_searcher\n\nor\n\n    port install the_silver_searcher\n\n\n### Linux\n\n* Ubuntu \u003e= 13.10 (Saucy) or Debian \u003e= 8 (Jessie)\n\n        apt-get install silversearcher-ag\n* Fedora 21 and lower\n\n        yum install the_silver_searcher\n* Fedora 22+\n\n        dnf install the_silver_searcher\n* RHEL7+\n\n        yum install epel-release.noarch the_silver_searcher\n* Gentoo\n\n        emerge -a sys-apps/the_silver_searcher\n* Arch\n\n        pacman -S the_silver_searcher\n\n* Slackware\n\n        sbopkg -i the_silver_searcher\n\n* openSUSE\n\n        zypper install the_silver_searcher\n\n* CentOS\n\n        yum install the_silver_searcher\n\n* NixOS/Nix/Nixpkgs\n\n        nix-env -iA silver-searcher\n\n* SUSE Linux Enterprise: Follow [these simple instructions](https://software.opensuse.org/download.html?project=utilities\u0026package=the_silver_searcher).\n\n\n### BSD\n\n* FreeBSD\n\n        pkg install the_silver_searcher\n* OpenBSD/NetBSD\n\n        pkg_add the_silver_searcher\n\n### Windows\n\n* Win32/64\n\n  Unofficial daily builds are [available](https://github.com/k-takata/the_silver_searcher-win32).\n  \n* winget\n\n        winget install \"The Silver Searcher\"\n  \n  Notes:\n  - This installs a [release](https://github.com/JFLarvoire/the_silver_searcher/releases) of ag.exe optimized for Windows.\n  - winget is intended to become the default package manager client for Windows.  \n    As of June 2020, it's still in beta, and can be installed using instructions [there](https://github.com/microsoft/winget-cli).\n  - The setup script in the Ag's winget package installs ag.exe in the first directory that matches one of these criteria:\n     1. Over a previous instance of ag.exe *from the same [origin](https://github.com/JFLarvoire/the_silver_searcher)* found in the PATH\n     2. In the directory defined in environment variable bindir_%PROCESSOR_ARCHITECTURE%\n     3. In the directory defined in environment variable bindir\n     4. In the directory defined in environment variable windir\n  \n* Chocolatey\n\n        choco install ag\n* MSYS2\n\n        pacman -S mingw-w64-{i686,x86_64}-ag\n* Cygwin\n\n  Run the relevant [`setup-*.exe`](https://cygwin.com/install.html), and select \"the\\_silver\\_searcher\" in the \"Utils\" category.\n\n## Building from source\n\n### Building master\n\n1. Install dependencies (Automake, pkg-config, PCRE, LZMA):\n    * macOS:\n\n            brew install automake pkg-config pcre xz\n        or\n\n            port install automake pkgconfig pcre xz\n    * Ubuntu/Debian:\n\n            apt-get install -y automake pkg-config libpcre3-dev zlib1g-dev liblzma-dev\n    * Fedora:\n\n            yum -y install pkgconfig automake gcc zlib-devel pcre-devel xz-devel\n    * CentOS:\n\n            yum -y groupinstall \"Development Tools\"\n            yum -y install pcre-devel xz-devel zlib-devel\n    * openSUSE:\n\n            zypper source-install --build-deps-only the_silver_searcher\n\n    * Windows: It's complicated. See [this wiki page](https://github.com/ggreer/the_silver_searcher/wiki/Windows).\n2. Run the build script (which just runs aclocal, automake, etc):\n\n        ./build.sh\n\n   On Windows (inside an msys/MinGW shell):\n\n        make -f Makefile.w32\n3. Make install:\n\n        sudo make install\n\n\n### Building a release tarball\n\nGPG-signed releases are available [here](http://geoff.greer.fm/ag).\n\nBuilding release tarballs requires the same dependencies, except for automake and pkg-config. Once you've installed the dependencies, just run:\n\n    ./configure\n    make\n    make install\n\nYou may need to use `sudo` or run as root for the make install.\n\n\n## Editor Integration\n\n### Vim\n\nYou can use Ag with [ack.vim](https://github.com/mileszs/ack.vim) by adding the following line to your `.vimrc`:\n\n    let g:ackprg = 'ag --nogroup --nocolor --column'\n\nor:\n\n    let g:ackprg = 'ag --vimgrep'\n\nWhich has the same effect but will report every match on the line.\n\n### Emacs\n\nYou can use [ag.el][] as an Emacs front-end to Ag. See also: [helm-ag].\n\n[ag.el]: https://github.com/Wilfred/ag.el\n[helm-ag]: https://github.com/syohex/emacs-helm-ag\n\n### TextMate\n\nTextMate users can use Ag with [my fork](https://github.com/ggreer/AckMate) 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\"`\n\n## Other stuff you might like\n\n* [Ack](https://github.com/petdance/ack3) - Better than grep. Without Ack, Ag would not exist.\n* [ack.vim](https://github.com/mileszs/ack.vim)\n* [Exuberant Ctags](http://ctags.sourceforge.net/) - Faster than Ag, but it builds an index beforehand. Good for *really* big codebases.\n* [Git-grep](http://git-scm.com/docs/git-grep) - As fast as Ag but only works on git repos.\n* [fzf](https://github.com/junegunn/fzf) - A command-line fuzzy finder \n* [ripgrep](https://github.com/BurntSushi/ripgrep)\n* [Sack](https://github.com/sampson-chen/sack) - A utility that wraps Ack and Ag. It removes a lot of repetition from searching and opening matching files.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fggreer%2Fthe_silver_searcher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fggreer%2Fthe_silver_searcher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fggreer%2Fthe_silver_searcher/lists"}