Crates.io | grox |
lib.rs | grox |
version | |
source | src |
created_at | 2025-03-24 03:46:29.489433+00 |
updated_at | 2025-03-29 05:14:49.711028+00 |
description | Command-line tool that searches for regex matches in a file tree. |
homepage | |
repository | https://gitlab.com/nickeldan/grox |
max_upload_size | |
id | 1603354 |
Cargo.toml error: | TOML parse error at line 19, column 1 | 19 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
Grox is a command-line tool that searches a file tree for regex matches.
For example,
$ grox the
(1) ./lib.rs:19: ... / * `file` - Path to the file.
(2) ./lib.rs:20: ... e number (1-up) of the match.
(3) ./lib.rs:50: ... rror message if either `max_depth` was ...
(4) ./lib.rs:51: ... n't have access to the starting direct ...
(5) ./lib.rs:151: .and_then(|name| name.to ...
(6) ./lib.rs:152: .and_then(|name| name.ch ...
(7) ./lib.rs:314: ... oing to fold my clothes"
(8) ./main.rs:18: ... tory. Defaults to the current working ...
(9) ./main.rs:28: ... hort, help = "Open the file for the spec ...
By default the search starts with the current working directory. You can change this by -d DIRECTORY
.
You can limit the directory search depth by -p DEPTH
. A depth of 1 searches only the starting directory.
If you only want to get the names of the matching files, add -n
:
$ grox the -n
(1) ./lib:rs
(2) ./main.rs
If you only want to search files whose names match a certain pattern, you can use -f
:
$ grox the -f '\.rs$'
You can open the n-th match in an editor with the -l
option. For example, say you found these matches:
$ grox some_pattern
(1) file1.txt:55: ...
(2) file2:txt:2: ...
If you wanted to open up file1.txt, you could run the search again with -l
:
$ grox some_pattern -l 1
If the EDITOR
environment variable is set, then Grox will use the specified executable. Otherwise, it will try to use vim followed by vi. You can manually specify the editor by
$ grox some_pattern -l 1 -e less
If the chosen editor is either vim or vi, then Grox will open up the file to the line containing the match.
When you run a search without -l
, a history file is created at ~/.grox_history.json
. If you then re-run the exact same search with -l
, Grox will grab the result from the history file instead of re-running the search.
Every search that doesn't use -l
will overwrite the history file if it exists. That is, only the most recent search is saved.