Go to file
Alexandre Pasmantier eb396965df
Create rust.yml
2024-08-27 23:49:00 +02:00
.github/workflows Create rust.yml 2024-08-27 23:49:00 +02:00
src refactor: adjust max pre-allocated buffersize 2024-08-25 23:16:00 +02:00
.gitignore first commit 2024-07-21 01:56:54 +02:00
Cargo.lock refactor: adjust max pre-allocated buffersize 2024-08-25 23:16:00 +02:00
Cargo.toml refactor: adjust max pre-allocated buffersize 2024-08-25 23:16:00 +02:00
README.md Update README.md 2024-08-27 22:41:08 +02:00

Grip-grab 🧤

A circumstancially faster, more lightweight, ripgrep-inspired alternative.

 gg "\b(Read|Write)Half[^<]" tokio/src

https://github.com/user-attachments/assets/2c5ed221-77f4-4a75-9f1a-b96341f3313b

Installation

Using Cargo

cargo install grip-grab

NOTE: if using zsh with the git plugin, you might need to unalias gg in order for grip-grab's gg to work:

echo 'unalias gg' >> ~/.zshrc
source ~/.zshrc

Usage

 gg --help
A somewhat faster, more lightweight, ripgrep-inspired alternative.

Usage: gg [OPTIONS] [PATTERN] [PATHS]...

Arguments:
  [PATTERN]   a regex pattern to search for
  [PATHS]...  paths in which to search recursively

Options:
  -e, --patterns <PATTERNS>
          you can specify multiple patterns using -e "pattern1" -e "pattern2" etc
  -I, --ignore-paths <IGNORE_PATHS>
          paths to ignore when recursively walking target directory
  -G, --disregard-gitignore
          disregard .gitignore rules when recursively walking directory (defaults to false)
  -M, --max-results <MAX_RESULTS>
          upper boundary for the number of results to expect (will panic if #results > max_results) [default: 1000]
  -T, --n-threads <N_THREADS>
          number of threads to use [default: 4]
  -U, --multiline
          enable multiline matching
      --json
          output in JSON format
  -f, --file-paths-only
          output file paths only
  -A, --absolute-paths
          output absolute paths (defaults to relative)
  -C, --disable-colored-output
          disable colored output (colored by default)
  -t, --filter-filetypes <FILTER_FILETYPES>
          filter on filetype (defaults to all filetypes)
  -H, --disable-hyperlinks
          disable hyperlinks in output (defaults to false)
  -h, --help
          Print help
  -V, --version
          Print version

Benchmarks

Warning: this is just a couple of comparisons on different sizes of codebases to get an idea of the big numbers but not in any way does this pretend to be a rigorous and scientific benchmarking exercise. The general idea it tries to convey is that while rg and gg should yield similar performances since they share the same core crates, gg still might be (marginally) faster circumstancially.

The curl codebase (approx. half a milion lines)

Screenshot 2024-08-27 at 22 31 13

The tokio codebase (approx. 160k lines)

Screenshot 2024-08-27 at 22 37 11

Examples

Basic usage

 gg "\b(Read|Write)Half[^<]" tokio/src
Screenshot 2024-07-26 at 14 00 31

JSON output

 gg --json unsplit tokio/src | jq
Screenshot 2024-07-24 at 13 25 29

Filenames only

 gg -f "\b(Read|Write)Half[^<]" tokio/src
Screenshot 2024-07-24 at 13 29 52

Notes

This lightweight utility is largely based on a couple of crates from the extraordinary ripgrep tool. Its aim is to provide a minimal and lightweight version that can be easily integrated in other programs for search-related purproses.