ggreer/the_silver_searcher là dự án phía máy chủ trên GitHub với 27.1k sao, viết chủ yếu bằng C. A code-searching tool similar to ack, but faster.
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
A code searching tool similar to ack, with a focus on speed.
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 ack.
It ignores file patterns from your .gitignore and .hgignore.
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*)
The command name is 33% shorter than ack, 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 ~/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?
Ag uses Pthreads to take advantage of multiple CPU cores and search files in parallel.
Files are mmap()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 pcre_study() before executing the same regex on every file.
Instead of calling fnmatch() 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 scandir(), benchmarked every revision to find performance regressions, and profiled with gprof and Valgrind.
SUSE Linux Enterprise: Follow these simple instructions.
BSD
FreeBSD
pkg install the_silver_searcher
OpenBSD/NetBSD
pkg_add the_silver_searcher
Windows
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:
Over a previous instance of ag.exe from the same origin found in the PATH
In the directory defined in environment variable bindir_%PROCESSOR_ARCHITECTURE%
In the directory defined in environment variable bindir
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 setup-*.exe, and select "the_silver_searcher" in the "Utils" category.
Run the build script (which just runs aclocal, automake, etc):
./build.sh
On Windows (inside an msys/MinGW shell):
make -f Makefile.w32
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:
./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
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.
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/ggreer/the_silver_searcher là nguồn chính thức.
ggreer/the_silver_searcher có bao nhiêu sao?
ggreer/the_silver_searcher có 27.1k sao GitHub — tải lại trang để xem số mới nhất, hoặc xem trực tiếp github.com/ggreer/the_silver_searcher. TopGit phản chiếu số sao của GitHub nhưng không cam kết đến từng phút.
ggreer/the_silver_searcher có phải mã nguồn mở không?
Có — ggreer/the_silver_searcher phát hành theo license Apache-2.0, nghĩa là mã nguồn mở để đọc, fork và (tùy license) tái sử dụng. Mã: github.com/ggreer/the_silver_searcher.
ggreer/the_silver_searcher còn đang phát triển không?
Commit gần nhất trên ggreer/the_silver_searcher là 2.4 năm trước (theo timestamp GitHub). Repo có 1.4k fork — một chỉ báo về mức độ quan tâm của cộng đồng.
ggreer/the_silver_searcher là gì?
ggreer/the_silver_searcher (ggreer/the_silver_searcher) là dự án C trên GitHub. Theo mô tả gốc: A code-searching tool similar to ack, but faster.
ggreer/the_silver_searcher so với các dự án Backend khác thế nào?
ggreer/the_silver_searcher được TopGit xếp vào nhóm Backend, với 27.1k sao GitHub và viết bằng C. Xem trang chủ đề Backend trên TopGit để so sánh với các dự án tương tự theo số sao và mức độ hoạt động.
Đọc đầy đủ README ở tab phía trên.
Vẫn đang phân vân về the_silver_searcher?
Một cú bấm sẽ gửi câu hỏi kèm trang này cho AI — xem AI nói gì về the_silver_searcher.