#regex #search-pattern #pattern #command-line-tool #tree-structure #grep #ripgrep

app gret

gret is a command line tool to search for patterns and show matches in a tree structure

3 releases

0.1.2 Nov 5, 2023
0.1.1 Jun 10, 2023
0.1.0 Jun 3, 2023

#496 in Text processing

37 downloads per month

Unlicense

1MB
1.5K SLoC

Rust 1K SLoC // 0.1% comments BASH 55 SLoC PowerShell 44 SLoC Elvish 41 SLoC Shell 23 SLoC // 0.1% comments

gret

gret (Global Regular Expression Tree) is a command-line utility designed to search through directories and files for a regex expression that matches while respecting .gitignore and .ignore files, the results are presented in a tree format and a menu can be spawned to select from.

https://github.com/4imothy/gret/assets/40186632/07043fef-4376-433a-90a2-33c3913570dd

Quick Install

cargo install gret

To Run

Use cargo run, the first positional argument is the pattern, the second is the path to search. If you want to match multiple patterns use -e followed by the pattern.

To launch a menu use the flag -m or --menu, this will open a match picker. After selecting one by pression enter the file/directory will be launched by $EDITOR if on unix or start if on windows. If $EDITOR is not found, then open will be called on macos and xdg-open will be called on other non-windows operating systems.

How To Use

See the options.md file.

To Install

cargo install gret

or

Run the ./add_to_path.sh script after changing the links location to somewhere on your path. Or run the commands seperately:

cargo build --release

And then source the correct completion file that is in the completions/ directory.

To Benchmark

Run ./benchmarks/bench at the root directory. Results can be seen in the times file in the benchmarks directory.

Then add the binary to your path and then source the script to give you proper completions. For the completions to work on next login you must source it at each login.

Shell Completion Script to Source
BASH completions/gret.bash
Zsh completions/_gret
Fish completions/gret.fish
Elvish completions/gret.elv
PowerShell _gret.ps1

Dependencies

~6–17MB
~191K SLoC