Fuzzy search over your local browser history across all browsers
bhgrep is a blazing-fast command-line tool that lets you search through your browser history across Chrome, Firefox, Safari, and Edge with fuzzy matching, regex support, and an interactive TUI.
- π Fuzzy Search - Find pages even with typos or partial matches
- π― Regex Support - Powerful pattern matching for advanced queries
- π₯οΈ Interactive TUI - Beautiful terminal interface for browsing results
- π CLI Mode - Script-friendly output with JSON, plain text, or URL-only formats
- π Multi-Browser - Automatically searches Chrome, Firefox, Safari, and Edge
- β‘ Smart Scoring - Prioritizes recent and frequently visited pages
- π Quick Actions - Open URLs or copy to clipboard with a single keystroke
- π Fast - Efficient indexing and caching for instant results
git clone https://github.com/jondot/bhgrep.git
cd bhgrep
cargo build --releaseThe binary will be at target/release/bhgrep. You can add it to your PATH:
sudo cp target/release/bhgrep /usr/local/bin/cargo install bhgrepSimply run bhgrep without arguments to enter interactive mode:
bhgrepKeyboard shortcuts:
- Type to search
Enter: Open selected URL in browsery: Copy URL to clipboardEscorq: Quitβ/β: Navigate resultsCtrl+U: Clear search
Search with a query:
bhgrep --query "rust programming"# Search and output as JSON
bhgrep -q "rust" --format json
# Get only URLs (perfect for scripting)
bhgrep -q "tutorial" --format url-only
# Open first result in browser
bhgrep -q "github" --open
# Copy first result URL to clipboard
bhgrep -q "stackoverflow" --copy
# Search only Chrome history
bhgrep -q "documentation" --browser chrome
# Use regex for pattern matching
bhgrep --mode regex -q "github\.com/.*/.*" --format url-only# Find all GitHub repos you've visited
bhgrep -q "github.com" --format url-only | grep -E "github\.com/[^/]+/[^/]+" | sort -u
# Export full history as JSON for analysis
bhgrep -q "" --format json --limit 10000 > history.json
# Search with custom limit
bhgrep -q "documentation" --limit 50
# Use database mode for faster startup (slower queries)
bhgrep -q "search term" --mode dbplain(default): Human-readable format with title, URL, and metadatajson: JSON format perfect for scripting and automationurl-only: Just URLs, one per line
# Quick alias for documentation lookup
alias doc='bhgrep -q "$1" --format url-only --open'
# Find all Stack Overflow answers you've visited
bhgrep -q "stackoverflow.com" --format url-only
# Collect resources for a project
bhgrep -q "myproject" --format json | jq '.[] | .url' > resources.txt# Export sensitive history for analysis
bhgrep -q "token=" --format json --limit 50000 > full_history.json
# Find visits to specific domains
bhgrep --mode regex -q "example\.com" --format json
# Timeline analysis
bhgrep -q "target" --format json | jq -r '.[] | "\(.last_visit) | \(.url)"' | sort- β Google Chrome - Full support
- β Mozilla Firefox - Full support
- β Safari - Full support (macOS only)
- β Microsoft Edge - Full support
The tool automatically detects available browsers and searches across all of them.
USAGE:
bhgrep [OPTIONS]
OPTIONS:
-q, --query <QUERY> Search query (enables non-interactive mode)
-n, --limit <LIMIT> Limit number of results [default: 10]
--format <FORMAT> Output format: plain, json, or url-only [default: plain]
--open Open first result in browser
--copy Copy first result URL to clipboard
--browser <BROWSER> Filter by browser: chrome, firefox, safari, or edge
--mode <MODE> Search mode: fuzzy, db, or regex [default: fuzzy]
--cache-freshness <SECS> Cache freshness in seconds [default: 600]
-h, --help Print help information
-V, --version Print version information
fuzzy(default): Loads all history to memory, then performs fast fuzzy searchdb: Queries database directly on each search (faster startup, slower queries)regex: Loads all history to memory, then performs regex pattern matching
- Rust 1.70 or later
- Cargo
# Debug build
cargo build
# Release build (optimized)
cargo build --releasecargo testcargo clippy --all-targets --all-features -- -D warningscargo fmt --all -- --checkbhgrep/
βββ src/
β βββ browsers/ # Browser-specific history readers
β β βββ chrome.rs
β β βββ firefox.rs
β β βββ safari.rs
β β βββ edge.rs
β βββ search.rs # Search algorithms (fuzzy, regex)
β βββ scoring.rs # Scoring and ranking logic
β βββ tui.rs # Terminal UI
β βββ output.rs # Output formatting
β βββ main.rs # CLI entry point
βββ .github/
β βββ workflows/
β βββ ci.yml # CI/CD pipeline
βββ Cargo.toml
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
# Clone the repository
git clone https://github.com/jondot/bhgrep.git
cd bhgrep
# Run tests
cargo test
# Run with logging
RUST_LOG=debug cargo run -- -q "test"This project is licensed under the MIT License - see the LICENSE file for details.
- Built with Rust
- Uses ratatui for the TUI
- Uses fuzzy-matcher for fuzzy search
- Inspired by tools like
fzfandripgrep
bhgrep is optimized for speed:
- Fuzzy mode: Fast queries after initial load (~100ms for 10k entries)
- DB mode: Fast startup, queries database directly
- Smart caching: Browser databases are cached to avoid repeated file operations
- Efficient scoring: Only clones entries that make it to final results
- Make sure you have browser history in supported browsers
- Try a broader search query
- Check that browsers are installed and have history
- Grant Full Disk Access to Terminal/iTerm in System Preferences
- Safari requires Full Disk Access to read its history database
- Use
--mode dbfor faster startup if you have large history - Reduce
--limitfor faster results - Consider using
--browserto search only specific browsers
- fzf - A command-line fuzzy finder
- ripgrep - A line-oriented search tool
- browser-history - Python browser history tool
Made with β€οΈ by @jondot
If you find bhgrep useful, please consider giving it a β on GitHub!