rfgrep
A command-line utility for recursively searching and listing files with advanced filtering capabilities. Built in Rust.
Features
-
Advanced Search
- Regex, plain text, and whole-word matching
- Recursive directory traversal
- Binary file detection
- Extension filtering
- Size limits
-
File Listing
- Detailed/simple output formats
- Extension statistics
- Size filtering
- Hidden file handling
-
Utilities
- Clipboard copy support
- Dry-run mode
- Logging to file
- Progress indicators
-
Unix Pipeline Integration
- Automatic quiet mode when piped
- Seamless integration with grep, awk, sed, xargs
- Count-only mode (
-c) - Files-with-matches mode (
-l)
-
Output Formats (v0.4.0)
- CSV export for spreadsheet analysis
- TSV export for tab-separated data
- JSON, XML, HTML, Markdown formats
- NDJSON for streaming JSON
Installation
Assuming you have Rust installed, run:
Via Cargo
From GitHub
From Source
Installing Man Pages
After installing rfgrep, you can install the comprehensive man pages:
System-wide Installation (requires sudo)
User Installation (no sudo required)
Then add to your shell profile (.bashrc, .zshrc, etc.):
Installing Shell Completions
rfgrep supports tab completion for all major shells:
Bash
# Generate and source completion
Zsh
# Generate completion file
# Add to .zshrc
&&
Fish
# Generate and install
PowerShell
# Generate and import
Usage
Basic Search
Search with Options
File Listing
# Simple list
# Detailed view
# With filters
Documentation
See DESIGN_OPTIMIZATION.md for the latest simulation findings and the optimized framework proposal, including cross-disciplinary applications and roadmap.
Simulations
Quickly run built-in simulations and write a CSV report to ./results/simulations.csv:
You can change the working directory with --path to select a corpus (defaults to . and prefers ./bench_data if present).
Man Pages
After installation, comprehensive man pages are available:
# Main man page
# Command-specific man pages
The man pages include:
- Complete command reference
- Detailed option descriptions
- Practical examples
- Performance tips
- Troubleshooting guides
Shell Completions
Once installed, tab completion provides:
- Command completion (
rfgrep <TAB>) - Option completion (
rfgrep search --<TAB>) - Extension completion (
--extensions <TAB>) - File path completion (
src/<TAB>)
Troubleshooting
Man Pages Not Found
# Check if man pages are installed
# Add to shell profile if needed
Completions Not Working
# Regenerate completions
# Reload shell configuration
# For zsh, ensure completion directory exists
# For fish, install to user directory
Performance Issues
# Use dry-run to preview
# Skip binary files
# Limit file size
# Use specific extensions
Shell-Specific Troubleshooting
Bash:
# Check if completion is loaded
|
# Manual installation
Zsh:
# Check completion directory
# Reload completions
&&
Fish:
# Check if completion is installed
# Manual installation
Command Reference
Global Options
| Option | Description |
|---|---|
--log PATH |
Write logs to specified file |
--path DIR |
Base directory (default: .) |
Search Command
| Option | Description |
|---|---|
--mode MODE |
Search mode: regex/text/word |
--extensions EXT |
Comma-separated file extensions |
--max-size MB |
Skip files larger than specified MB |
--skip-binary |
Skip binary files |
--dry-run |
Preview files without processing |
--copy |
Copy results to clipboard |
--quiet, -q |
Suppress non-essential output (v0.4.0) |
--count, -c |
Show only count of matches (v0.4.0) |
--files-with-matches, -l |
Show only filenames with matches (v0.4.0) |
--output-format |
Output format: text/json/csv/tsv/xml/html/markdown |
--ndjson |
Output newline-delimited JSON (v0.4.0) |
--safety-policy |
Safety policy: default/conservative/performance |
--threads N |
Number of threads for parallel processing |
--file-types |
File type strategy: default/comprehensive/conservative/performance |
--include-extensions |
Override to include specific file types |
--exclude-extensions |
Override to exclude specific file types |
--search-all-files |
Search all file types (comprehensive mode) |
--text-only |
Only search text files (conservative mode) |
List Command
| Option | Description |
|---|---|
--extensions EXT |
Comma-separated file extensions |
--long |
Detailed output format |
--recursive |
Recursive directory traversal |
--show-hidden |
Include hidden files/directories |
--max-size MB |
Skip files larger than specified MB |
--skip-binary |
Skip binary files |
Examples
- Find all Rust files containing "HashMap":
- List all Markdown files under 1MB:
- Search with regex and copy to clipboard:
- New in v0.4.0: Count-only mode (like
grep -c):
# Output: 42
- New in v0.4.0: Files-with-matches mode (like
grep -l):
# Output: List of files containing TODO
- New in v0.4.0: CSV export for analysis:
- New in v0.4.0: Unix pipeline integration:
# Count matches per file
| | |
# Process files with xargs
|
# Filter with grep
|
- Advanced file type control:
- Simulation and benchmarking:
Performance Tips
- Use
--skip-binaryto avoid unnecessary file checks - Limit scope with
--extensionsand--max-size - For large directories,
--dry-runfirst to preview - Use
--safety-policy performancefor faster processing - Adjust
--threadsbased on your CPU cores - Use
--file-types conservativefor safe text-only search
Advanced Usage
Interactive Mode
# Start interactive search
# Interactive search with specific algorithm
# Interactive search in specific file types
Output Formats
# JSON output for programmatic processing
# NDJSON (newline-delimited JSON) for streaming
# CSV output for spreadsheet analysis (v0.4.0)
# TSV output for tab-separated data (v0.4.0)
# XML output for structured data
# HTML output for web display
# Markdown output for documentation
Search Algorithms
# Boyer-Moore (fast for plain text)
# Regular expression
# Simple linear search
Verification
Test Man Pages
# Verify man pages are accessible
Test Shell Completions
# Bash: Type 'rfgrep ' and press TAB
# Zsh: Type 'rfgrep ' and press TAB
# Fish: Type 'rfgrep ' and press TAB
Test Basic Functionality
# Test search functionality
# Test list functionality
# Test interactive mode
Clipboard behavior in CI/headless environments
Note: the --copy option attempts to use the system clipboard and may fail in headless CI environments (X11/Wayland not available). In those environments run without --copy or provide a virtual display (Xvfb) or configure your CI to provide a clipboard service. The application will log a warning if the clipboard operation times out.
Automated Testing
# Test shell completions
# Test man pages
Contributing
Contributions are welcome! Please open an issue or PR for any:
- Bug reports
- Feature requests
- Performance improvements