Convert Figma logo to code with AI

monochromegane logothe_platinum_searcher

A code search tool similar to ack and the_silver_searcher(ag). It supports multi platforms and multi encodings.

2,806
141
2,806
46

Top Related Projects

48,187

ripgrep recursively searches directories for a regex pattern while respecting your gitignore

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

33,285

A simple, fast and user-friendly alternative to 'find'

64,567

:cherry_blossom: A command-line fuzzy finder

2,956

:mag: A simple, fast fuzzy finder for the terminal

2,567

NEW ugrep 6.5: a more powerful, ultra fast, user-friendly, compatible grep. Includes a TUI, Google-like Boolean search with AND/OR/NOT, fuzzy search, hexdumps, searches (nested) archives (zip, 7z, tar, pax, cpio), compressed files (gz, Z, bz2, lzma, xz, lz4, zstd, brotli), pdfs, docs, and more

Quick Overview

The Platinum Searcher (pt) is a fast code search tool similar to ack and The Silver Searcher (ag). It's written in Go and designed to be a faster and more feature-rich alternative to other code search tools. The Platinum Searcher supports various file types and offers options for customizing search behavior.

Pros

  • Fast performance, especially for large codebases
  • Supports a wide range of file types and programming languages
  • Offers advanced features like regex search and ignore files
  • Cross-platform compatibility (Windows, macOS, Linux)

Cons

  • Less widely adopted compared to alternatives like ripgrep
  • May require manual installation on some systems
  • Documentation could be more comprehensive
  • Development appears to be less active in recent years

Getting Started

To install The Platinum Searcher:

# On macOS with Homebrew
brew install pt

# On Ubuntu/Debian
sudo apt-get install pt-search

# From source
go get -u github.com/monochromegane/the_platinum_searcher/...

Basic usage:

# Search for "pattern" in current directory
pt pattern

# Search with regex
pt -e "regex_pattern"

# Search in specific directory
pt pattern /path/to/directory

# Ignore case
pt -i pattern

For more options and advanced usage, refer to the project's README or run pt --help.

Competitor Comparisons

48,187

ripgrep recursively searches directories for a regex pattern while respecting your gitignore

Pros of ripgrep

  • Significantly faster performance, especially for large codebases
  • More comprehensive feature set, including better Unicode support
  • Actively maintained with frequent updates and improvements

Cons of ripgrep

  • Larger binary size due to more features and dependencies
  • Steeper learning curve for advanced features and configuration options

Code comparison

ripgrep:

use grep_regex::RegexMatcher;
use grep_searcher::Searcher;
use ignore::WalkBuilder;

let matcher = RegexMatcher::new(r"pattern").unwrap();
let mut searcher = Searcher::new();

the_platinum_searcher:

import (
    "github.com/monochromegane/the_platinum_searcher/search"
)

searcher := search.Searcher{Pattern: "pattern"}
searcher.Search()

The code snippets demonstrate the basic setup for searching in both tools. ripgrep uses a more modular approach with separate matcher and searcher components, while the_platinum_searcher has a simpler, more integrated structure. ripgrep's approach allows for more flexibility and customization, but may require more initial setup.

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

Pros of The Silver Searcher

  • Written in C, which generally offers better performance
  • More mature project with a larger user base and longer development history
  • Supports a wider range of platforms and operating systems

Cons of The Silver Searcher

  • Less actively maintained in recent years
  • Fewer advanced features compared to The Platinum Searcher
  • May have slower search speeds for certain file types or encodings

Code Comparison

The Platinum Searcher (Go):

func (p *Platinum) Search(root string, pattern *regexp.Regexp) ([]*Line, error) {
    lines := []*Line{}
    err := filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
        // Search implementation
    })
    return lines, err
}

The Silver Searcher (C):

void search_dir(ignores *ig, const char *base_path, const char *path, const int depth) {
    DIR *dir;
    struct dirent *dir_entry;
    // Search implementation
}

Both projects aim to provide fast file searching capabilities, but they differ in their implementation languages and specific features. The Platinum Searcher offers some advanced features and may have better performance for certain use cases, while The Silver Searcher has a more established presence and wider platform support.

33,285

A simple, fast and user-friendly alternative to 'find'

Pros of fd

  • Faster performance, especially for large directories
  • More user-friendly syntax and default behavior
  • Better cross-platform support (Windows, macOS, Linux)

Cons of fd

  • Less extensive regex support compared to the_platinum_searcher
  • Fewer advanced search options and customization features
  • Not designed for code-specific searching like the_platinum_searcher

Code comparison

fd:

fd pattern
fd -e txt
fd -x command {} \;

the_platinum_searcher:

pt pattern
pt --file-search-regexp=\.txt$
pt -g '*.txt' pattern

Key differences

  • fd focuses on simplicity and speed for general file searching
  • the_platinum_searcher is optimized for code searching with more advanced features
  • fd uses a more intuitive syntax, while the_platinum_searcher follows grep-like conventions
  • the_platinum_searcher offers more powerful regex capabilities
  • fd provides better default ignore patterns for common version control systems and build artifacts

Both tools have their strengths, with fd being more suitable for quick file searches and the_platinum_searcher excelling in code-specific search scenarios. The choice between them depends on the user's specific needs and preferences.

64,567

:cherry_blossom: A command-line fuzzy finder

Pros of fzf

  • Versatile fuzzy finder for command-line and can be integrated into various tools and workflows
  • Faster performance for interactive searching and filtering
  • More actively maintained with frequent updates and improvements

Cons of fzf

  • Not specifically designed for code searching like the_platinum_searcher
  • Requires additional configuration for advanced code search features
  • May have a steeper learning curve for some users

Code Comparison

fzf (interactive fuzzy finding):

find * -type f | fzf > selected

the_platinum_searcher (code searching):

pt "search pattern" /path/to/search

While fzf is primarily an interactive fuzzy finder, the_platinum_searcher is designed specifically for code searching. fzf excels in versatility and speed for general-purpose filtering, while the_platinum_searcher offers more specialized features for searching through code repositories.

fzf can be integrated into various tools and workflows, making it highly adaptable. On the other hand, the_platinum_searcher provides out-of-the-box functionality for code searching without requiring additional configuration.

Both tools have their strengths, and the choice between them depends on the specific use case and user preferences.

2,956

:mag: A simple, fast fuzzy finder for the terminal

Pros of fzy

  • Lightweight and fast fuzzy finder
  • Simple and easy to use interface
  • Can be easily integrated into other tools and scripts

Cons of fzy

  • Limited to fuzzy finding functionality
  • Lacks advanced search features like regex support
  • Not optimized for searching large codebases or directories

Code comparison

fzy:

int match(char const *needle, char const *haystack) {
    while (*needle && *haystack) {
        if (tolower(*needle) == tolower(*haystack++))
            needle++;
    }
    return !*needle;
}

the_platinum_searcher:

func (g *Grep) Search(root string, pattern *Pattern) (*Result, error) {
    grep := make(chan *GrepResult)
    go g.grep(root, pattern, grep)
    return g.aggregate(grep), nil
}

fzy is a lightweight fuzzy finder written in C, focusing on simplicity and speed for interactive use. It's great for quickly finding files or selecting options from a list.

the_platinum_searcher, on the other hand, is a more comprehensive code search tool written in Go. It offers advanced features like regex support, ignore files, and multi-core utilization, making it better suited for searching large codebases or directories.

While fzy excels in its specific use case of fuzzy finding, the_platinum_searcher provides a broader range of functionality for code and file searching tasks.

2,567

NEW ugrep 6.5: a more powerful, ultra fast, user-friendly, compatible grep. Includes a TUI, Google-like Boolean search with AND/OR/NOT, fuzzy search, hexdumps, searches (nested) archives (zip, 7z, tar, pax, cpio), compressed files (gz, Z, bz2, lzma, xz, lz4, zstd, brotli), pdfs, docs, and more

Pros of ugrep

  • Supports a wider range of file formats and encoding types
  • Offers more advanced search options and regular expression features
  • Provides better performance for large-scale searches

Cons of ugrep

  • More complex command-line interface, which may be overwhelming for beginners
  • Larger installation size due to additional features and dependencies

Code Comparison

ugrep:

ugrep -Q 'pattern' file.txt
ugrep -r -n 'pattern' directory/
ugrep -i -w '\bword\b' *.txt

the_platinum_searcher:

pt 'pattern' file.txt
pt -r 'pattern' directory/
pt -i -w 'word' *.txt

Both tools offer similar basic functionality, but ugrep provides more advanced options and flexibility in its command-line interface. the_platinum_searcher focuses on simplicity and ease of use, making it more accessible for users who need quick and straightforward searches.

ugrep excels in handling complex search scenarios and large-scale operations, while the_platinum_searcher is better suited for simpler, everyday search tasks. The choice between the two depends on the user's specific needs and level of expertise in using command-line search tools.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

The Platinum Searcher Build Status wercker status

A code search tool similar to ack and the_silver_searcher(ag). It supports multi platforms and multi encodings.

Features

  • It searches code about 3–5× faster than ack.
  • It searches code as fast as the_silver_searcher(ag).
  • It ignores file patterns from your .gitignore.
  • It ignores directories with names that start with ., eg .config. Use --hidden option, if you want to search.
  • It searches UTF-8, EUC-JP and Shift_JIS files.
  • It provides binaries for multi platform (macOS, Windows, Linux).

Benchmarks

cd ~/src/github.com/torvalds/linux
ack EXPORT_SYMBOL_GPL 30.18s user 2.32s system  99% cpu 32.613 total # ack
ag  EXPORT_SYMBOL_GPL  1.57s user 1.76s system 311% cpu  1.069 total # ag: It's faster than ack.
pt  EXPORT_SYMBOL_GPL  2.29s user 1.26s system 358% cpu  0.991 total # pt: It's faster than ag!!

Usage

$ # Recursively searches for PATTERN in current directory.
$ pt PATTERN

$ # You can specify PATH and some OPTIONS.
$ pt OPTIONS PATTERN PATH

Configuration

If you put configuration file on the following directories, pt use option in the file.

  • $XDG_CONFIG_HOME/pt/config.toml
  • $HOME/.ptconfig.toml
  • .ptconfig.toml (current directory)

The file is TOML format like the following.

color = true
context = 3
ignore = ["dir1", "dir2"]
color-path = "1;34"

The options are same as command line options.

Editor Integration

Vim + Unite.vim

You can use pt with Unite.vim.

nnoremap <silent> ,g :<C-u>Unite grep:. -buffer-name=search-buffer<CR>
if executable('pt')
  let g:unite_source_grep_command = 'pt'
  let g:unite_source_grep_default_opts = '--nogroup --nocolor'
  let g:unite_source_grep_recursive_opt = ''
  let g:unite_source_grep_encoding = 'utf-8'
endif

Emacs + pt.el

You can use pt with pt.el, which can be installed from MELPA.

Installation

Developer

$ go get -u github.com/monochromegane/the_platinum_searcher/...

User

Download from the following url.

Or, you can use Homebrew (Only macOS).

$ brew install pt

pt is an alias for the_platinum_searcher in Homebrew.

Contribution

  1. Fork it
  2. Create a feature branch
  3. Commit your changes
  4. Rebase your local changes against the master branch
  5. Run test suite with the go test ./... command and confirm that it passes
  6. Run gofmt -s
  7. Create new Pull Request

License

MIT

Author

monochromegane