Skip to content

jrodolfo/extended-grep

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

extended-grep

CI License: MIT

extended-grep is a wrapper around rg (ripgrep) that saves search results as HTML files in ~/search-results.

Why use extended-grep

  • Better handling for tricky search strings in day-to-day usage (for example: search "fox, ").
  • Search results are written to HTML reports, so your terminal stays clean even for large searches.
  • Optional TXT reports (--format txt) are useful on terminal-only Linux servers.

Example:

search "fox, "

This creates an HTML report in ~/search-results.

Visual Example

Command usage:

Command usage

Search result for search fox:

Search result fox

Search result for search "fox, ":

Search result fox comma

Features

  • Recursive project search with profiles (grepx, code, xml, filename, etc.)
  • Colorized HTML output per search for faster visual scanning
  • Works on macOS, Linux, and Windows

Project Layout

  • scripts/runtime/: runtime search implementation (search.sh, search.ps1, grepfunctions.sh)
  • scripts/install/: platform installers
  • scripts/uninstall/: platform uninstallers
  • scripts/tests/: smoke tests and fixtures

Prerequisites

  • ripgrep (rg) installed and available on PATH

macOS:

brew install ripgrep

Windows (PowerShell):

winget install BurntSushi.ripgrep.MSVC

Linux:

# Amazon Linux / Fedora / RHEL (dnf)
sudo dnf install -y ripgrep

# Ubuntu / Debian (apt)
sudo apt-get update && sudo apt-get install -y ripgrep

Amazon Linux 2023 note:

  • If dnf install ripgrep returns “No match for argument”, install via Rust toolchain:
sudo dnf install -y cargo
cargo install ripgrep
echo 'export PATH="$HOME/.cargo/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
  • yum and dnf are equivalent on Amazon Linux 2023, so switching from one to the other usually does not change package availability.

Install on macOS

  1. Clone this repository.
  2. Run:
./scripts/install/install-macos.sh
  1. Open a new terminal and run:
search a-string

Install on Linux

  1. Clone this repository.
  2. Run:
./scripts/install/install-linux.sh
  1. Open a new terminal and run:
search a-string

Install on Windows (PowerShell)

  1. Clone this repository.
  2. Run in PowerShell:
./scripts/install/install-windows.ps1
  1. If script execution is blocked, run once (current user):
Set-ExecutionPolicy -Scope CurrentUser RemoteSigned
  1. Run right away in the same PowerShell session:
search a-string
  1. If search is still not found in the same session, load your profile once:
. $PROFILE
search a-string
  1. For future sessions, open a new PowerShell window and run:
search a-string

Troubleshooting:

Get-Command search -All
Test-Path $PROFILE

If your shell is started with -NoProfile, profile-based functions (including search) will not load automatically.

Uninstall

macOS:

./scripts/uninstall/uninstall-macos.sh

Linux:

./scripts/uninstall/uninstall-linux.sh

Windows (PowerShell):

./scripts/uninstall/uninstall-windows.ps1

Uninstall scripts remove installed files from your user home and clean the alias/profile line added during install.

Usage

search
search [OPTIONS] STRING
search [OPTIONS] PROFILE STRING

Running search with no arguments prints the help with all options.

Profiles:

  • grepx (default)
  • codescan
  • android
  • code
  • web
  • java
  • java_filename
  • javascript
  • xhtml
  • css
  • sql
  • xml
  • docs
  • filename
  • x_filename
  • jar

Examples:

search a-string
search --profile-list
search --version
search --format txt fox
search --deep a-string
search --max-per-file 50 a-string
search --format txt --context 0 --max-per-file 2 --max-scan-lines 500 --max-render-lines 200 fox
search xml another-string
search filename part-of-file-name

Options:

  • --version: print version and exit
  • --profile-list: print available profiles and exit
  • --format html|txt: choose output format (default html)
  • --open: open the generated report after search
  • --deep or --hidden: include hidden files/directories (slower)
  • --context N: context lines before/after each hit (default 3)
  • --max-per-file N: limit matches per file (default 200, 0 disables limit)
  • --max-filesize SIZE: skip files larger than SIZE (default 1M, use none to disable)
  • --max-scan-lines N: cap lines collected from rg before rendering (default 20000, 0 disables cap)
  • --max-line-length N: trim very long result lines before rendering (default 2000, 0 disables trimming)
  • --max-render-lines N: cap rendered report lines (default 12000, 0 disables cap)

Each run creates a report file in ~/search-results:

  • default: .html
  • with --format txt: .txt

Optional override:

  • Set SEARCH_RESULTS_DIR to write results to a custom directory.
  • Set SEARCH_CONFIG_FILE to point to a custom profile/default config file.

Shared config:

  • Profiles and default limits are centralized in config/search-profiles.conf.
  • Both scripts/runtime/search.sh and scripts/runtime/search.ps1 read this file to avoid config drift.

Notes

  • The generated HTML is plain and portable (no browser plugins required).
  • File naming is sanitized for cross-platform compatibility.
  • You can still run scripts directly from the repo:

macOS/Linux shell:

./scripts/runtime/search.sh STRING
./scripts/runtime/search.sh PROFILE STRING

Windows PowerShell:

./scripts/runtime/search.ps1 STRING
./scripts/runtime/search.ps1 PROFILE STRING

Smoke Tests

macOS / bash:

bash ./scripts/tests/smoke.tests.mac.sh

Linux / bash:

bash ./scripts/tests/smoke.tests.linux.sh

Windows PowerShell:

Invoke-Pester ./scripts/tests/smoke.tests.windows.ps1

Make targets:

make
make help
make test-mac
make test-linux
make test-ps
make test
make run ARGS="fox"
make uninstall-mac
make uninstall-linux
make uninstall-windows
  • make / make help: list available targets
  • make run ARGS="...": run search.sh with custom arguments

Windows note:

  • The make commands above require make to be installed.
  • Run the install commands from PowerShell.
  • Option 1 (Scoop, recommended):
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
irm get.scoop.sh | iex
scoop install make
  • Option 2 (winget standalone make):
winget install GnuWin32.Make
  • Option 3 (Git Bash, which also includes make in many setups):
winget install Git.Git
  • After installing, close and reopen PowerShell before running make.

CI

  • GitHub Actions runs smoke tests on every push and pull request:
    • Linux: make test-linux
    • macOS: make test-mac
    • Windows: Invoke-Pester ./scripts/tests/smoke.tests.windows.ps1

Contact

License

  • MIT License
  • Copyright (c) 2026 Rod Oliveira
  • See LICENSE

About

Cross-platform ripgrep wrapper that saves searchable HTML or TXT reports with profile-based filters for code, docs, XML, filenames, and more.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors