### Install direnv with Nix Source: https://github.com/phiresky/ripgrep-all/blob/master/README.md Installs the direnv utility using Nix. direnv helps manage environment variables for development projects. ```bash nix profile install nixpkgs#direnv ``` -------------------------------- ### Install rga with Scoop on Windows Source: https://github.com/phiresky/ripgrep-all/blob/master/README.md Use Scoop to install the rga package on Windows. This is a supported download method that includes necessary dependencies. ```bash scoop install rga ``` -------------------------------- ### Install rga with Homebrew on macOS/Linux Source: https://github.com/phiresky/ripgrep-all/blob/master/README.md Install rga using Homebrew on macOS or Linuxbrew. Optional useful dependencies like pandoc, poppler, and ffmpeg can also be installed. ```bash brew install rga ``` ```bash brew install pandoc poppler ffmpeg ``` -------------------------------- ### Launch `rga-fzf` with a Pre-filled Query Source: https://context7.com/phiresky/ripgrep-all/llms.txt Initiates an interactive fuzzy search with `rga-fzf`, starting with a specific query already entered. ```bash # Start with a pre-filled query rga-fzf "invoice 2024" ``` -------------------------------- ### Custom Adapter Configuration for Ripgrep-All Source: https://context7.com/phiresky/ripgrep-all/llms.txt Illustrates the JSONC configuration for defining a custom adapter in ripgrep-all. This example shows how to configure pandoc to convert reStructuredText files to plain text. ```jsonc { "name": "pandoc_rst", // unique a-z0-9_ identifier "version": 2, // bump when output format changes (invalidates cache) "description": "Convert reStructuredText to plain text via pandoc", "extensions": ["rst"], "mimetypes": ["text/x-rst"], "match_only_by_mime": false, // if true, extensions are ignored when --rga-accurate "disabled_by_default": false, "binary": "pandoc", "args": [ "--from=rst", "--to=plain", "--wrap=none", "$input_virtual_path" // full virtual path placeholder ], // output_path_hint controls what the next adapter sees as the filename. // Default is "${input_virtual_path}.txt". Set to another extension to chain adapters. // e.g. output a .tar so the tar adapter processes it next: "output_path_hint": "${input_virtual_path}.txt" } ``` -------------------------------- ### Install rga with Chocolatey on Windows Source: https://github.com/phiresky/ripgrep-all/blob/master/README.md Use Chocolatey to install the ripgrep-all package on Windows. This method ensures dependencies are also handled. ```bash choco install ripgrep-all ``` -------------------------------- ### Programmatic Adapter Filtering in Ripgrep-All (Rust API) Source: https://context7.com/phiresky/ripgrep-all/llms.txt Demonstrates using the `get_adapters_filtered` function in the Rust API to select specific file adapters. Examples show how to include, exclude, and prioritize adapters, including custom ones. ```rust use ripgrep_all::adapters::{get_adapters_filtered, CustomAdapterConfig}; // Use only the poppler (PDF) and sqlite adapters let adapters = get_adapters_filtered(None, &["poppler", "sqlite"])?; println!("Selected: {:?}", adapters.iter().map(|a| &a.metadata().name).collect::>()); // Selected: ["poppler", "sqlite"] // Use all default adapters except ffmpeg let adapters = get_adapters_filtered(None, &["-ffmpeg"])?; // Add the mail adapter on top of all defaults (highest priority) let adapters = get_adapters_filtered(None, &["+mail"])?; // Include a custom adapter config alongside defaults let custom = vec![CustomAdapterConfig { name: "my_converter".to_string(), version: 1, description: "Custom text extractor".to_string(), extensions: vec!["myext".to_string()], mimetypes: None, match_only_by_mime: None, binary: "/usr/local/bin/myconverter".to_string(), args: vec!["$input_virtual_path".to_string()], disabled_by_default: Some(false), output_path_hint: None, }]; let adapters = get_adapters_filtered(Some(custom), &[])?; ``` -------------------------------- ### Launch Interactive Search with `rga-fzf` Source: https://context7.com/phiresky/ripgrep-all/llms.txt Starts an interactive fuzzy search session using `rga-fzf`. The fzf UI displays matching files and provides a preview of matches within the selected file. ```bash # Launch interactive search in the current directory rga-fzf ``` -------------------------------- ### Configure ripgrep-all Cache Directory Source: https://context7.com/phiresky/ripgrep-all/llms.txt Specify a custom directory for the rga cache, for example, to use a faster SSD. ```bash rga --rga-cache-path=/mnt/fast-ssd/rga-cache "query" ./docs ``` -------------------------------- ### Configure Custom PDF Adapter for ripgrep-all Source: https://github.com/phiresky/ripgrep-all/wiki/Home Example configuration for a custom adapter that uses 'pdftotext' to extract text from PDF files. This adapter is useful for integrating external tools into the search process. ```json "custom_adapters": [ { "name": "poppler", "version": 1, "description": "Uses pdftotext (from poppler-utils) to extract plain text from PDF files", "extensions": ["pdf"], "mimetypes": ["application/pdf"], "binary": "pdftotext", "args": ["-", "-"], "disabled_by_default": false, "match_only_by_mime": false, "output_path_hint": "${input_virtual_path}.txt.asciipagebreaks" } ] ``` -------------------------------- ### Install rga with MacPorts on macOS Source: https://github.com/phiresky/ripgrep-all/blob/master/README.md Install rga using MacPorts on macOS. This command installs the ripgrep-all port. ```bash sudo port install ripgrep-all ``` -------------------------------- ### Compile rga from source Source: https://github.com/phiresky/ripgrep-all/blob/master/README.md Compile rga from source using Cargo. Ensure you have a compatible Rust version (v1.75.0+) and necessary build dependencies installed. ```bash apt install build-essential pandoc poppler-utils ffmpeg ripgrep cargo ``` ```bash cargo install --locked ripgrep_all ``` ```bash rga --version # this should work now ``` -------------------------------- ### Search Across All Built-in Formats with ripgrep-all Source: https://context7.com/phiresky/ripgrep-all/llms.txt Perform a search across all enabled built-in file formats, including mail archives. This example also enables accurate MIME-sniffing and sets a maximum recursion depth for archives. ```bash rga --rga-adapters=+mail \ --rga-accurate \ --rga-max-archive-recursion=5 \ "confidential" \ ~/Documents ~/Downloads ~/Mail ``` -------------------------------- ### Print Help Information Source: https://github.com/phiresky/ripgrep-all/blob/master/README.md Displays a concise overview of available commands and options for rga. ```bash -h ``` ```bash --help ``` -------------------------------- ### List Available Adapters Source: https://github.com/phiresky/ripgrep-all/blob/master/README.md Use this command to see all the file format adapters that ripgrep-all recognizes and can use for searching. ```bash rga --rga-list-adapters ``` -------------------------------- ### Verifying and Using Custom Ripgrep-All Adapters Source: https://context7.com/phiresky/ripgrep-all/llms.txt Provides bash commands to verify if a custom adapter is loaded and how to use it in searches. It also shows how to explicitly enable adapters that are disabled by default. ```bash # Verify the custom adapter is loaded rga --rga-list-adapters | grep pandoc_rst # Use it (enabled by default since disabled_by_default is false) rga "introduction" ./docs/guide.rst # Enable a disabled-by-default custom adapter explicitly rga --rga-adapters=+pandoc_rst "conclusion" ./reports/ ``` -------------------------------- ### Run Appropriate Adapter with rga_preproc (Rust API) Source: https://context7.com/phiresky/ripgrep-all/llms.txt Use `rga_preproc` to select and run the correct adapter for a given file. It returns an `AsyncRead` stream of plain text, handling recursive archive entries internally. Configure matching behavior using `RgaConfig`. ```rust use ripgrep_all::{ adapters::{AdaptInfo, ReadBox}, config::RgaConfig, preproc::rga_preproc, }; use std::path::PathBuf; use tokio::fs::File; use tokio::io::AsyncReadExt; #[tokio::main] async fn main() -> anyhow::Result<()> { let path = PathBuf::from("./exampledir/short.pdf"); let file = File::open(&path).await?; let config = RgaConfig { accurate: false, // use extension-based matching ..RgaConfig::default() }; let ai = AdaptInfo { filepath_hint: path.clone(), inp: Box::pin(file), is_real_file: true, archive_recursion_depth: 0, line_prefix: String::new(), postprocess: true, // prefix each line with "Page N: " config, }; let mut output: ReadBox = rga_preproc(ai).await?; let mut text = String::new(); output.read_to_string(&mut text).await?; println!("{text}"); // Page 1: hello world // Page 1: this is just a test. // Page 1: // Page 1: // 1 Ok(()) } ``` -------------------------------- ### Specify Adapters to Use Source: https://github.com/phiresky/ripgrep-all/blob/master/README.md Control which adapters are used and their priority. You can include, exclude, or add adapters to the default set. ```bash --rga-adapters=... ``` -------------------------------- ### Specify Configuration File Source: https://github.com/phiresky/ripgrep-all/blob/master/README.md Provide a custom path to the rga configuration file. ```bash --rga-config-file= ``` -------------------------------- ### Debug `rga-preproc` with Logging Source: https://context7.com/phiresky/ripgrep-all/llms.txt Enables debug logging for `rga-preproc` to show adapter selection and timing, useful for troubleshooting. ```bash # Debug mode: show which adapter was chosen and timing RUST_LOG=debug rga-preproc --rga-no-cache ./exampledir/wasteland.epub 2>&1 | head -30 ``` -------------------------------- ### Match File to Adapter with adapter_matcher (Rust API) Source: https://context7.com/phiresky/ripgrep-all/llms.txt Build a closure that maps `FileMeta` to the best matching adapter using `adapter_matcher`. Set `slow = true` for accurate MIME-type matching, or `false` for faster extension-based matching. ```rust use ripgrep_all::{ adapters::{get_all_adapters, get_adapters_filtered}, matching::{adapter_matcher, FileMeta}, }; let (enabled, _disabled) = get_all_adapters(None); let adapters = get_adapters_filtered(None, &[])?; // Build a fast extension-only matcher (slow = false) let matcher = adapter_matcher(&adapters, false)?; // Match a PDF by extension let result = matcher(FileMeta { lossy_filename: "report.pdf".to_string(), mimetype: None, }); if let Some((adapter, reason)) = result { println!("Matched adapter: {}", adapter.metadata().name); println!("Match reason: {:?}", reason); } // Matched adapter: poppler // Match reason: Fast(FileExtension("pdf")) // Build an accurate MIME-type matcher (slow = true) let slow_matcher = adapter_matcher(&adapters, true)?; let result = slow_matcher(FileMeta { lossy_filename: "datafile", // no extension mimetype: Some("application/x-sqlite3"), }); if let Some((adapter, _)) = result { println!("MIME match: {}", adapter.metadata().name); } // MIME match: sqlite ``` -------------------------------- ### ripgrep-all Configuration File (`config.jsonc`) Source: https://context7.com/phiresky/ripgrep-all/llms.txt Defines persistent configuration settings for ripgrep-all. Supports CLI options and custom adapters. Configuration is merged with environment variables and CLI arguments. ```jsonc // Location: ~/.config/ripgrep-all/config.jsonc (Linux/macOS XDG) // ~/Library/Application Support/ripgrep-all/config.jsonc (macOS) // %APPDATA%\ripgrep-all\config.jsonc (Windows) { "$schema": "./config.v1.schema.json", // Enable MIME-based matching globally "accurate": true, // Increase max archive nesting (default: 5) "max_archive_recursion": 10, // Adjust cache settings "cache": { "disabled": false, "max_blob_len": 5000000, // 5 MB "compression_level": 6, // zstd level 1-22, default 12 "path": "/home/user/.cache/rga" }, // Define custom subprocess-based adapters "custom_adapters": [ { "name": "djvu_text", "version": 1, "description": "Extracts text from DjVu files using djvutxt", "extensions": ["djvu"], "binary": "djvutxt", "args": ["$input_virtual_path", "-"], "disabled_by_default": false }, { "name": "rtf_to_text", "version": 1, "description": "Converts RTF to plain text via unrtf", "extensions": ["rtf"], "binary": "unrtf", "args": ["--text", "$input_virtual_path"], "disabled_by_default": false }, { "name": "image_ocr", "version": 1, "description": "OCR images using tesseract", "extensions": ["png", "jpg", "jpeg", "tiff"], "mimetypes": ["image/png", "image/jpeg", "image/tiff"], "match_only_by_mime": false, "binary": "tesseract", "args": ["$input_virtual_path", "stdout", "-l", "eng"], "disabled_by_default": true } ] } ``` -------------------------------- ### Print ripgrep Help Source: https://github.com/phiresky/ripgrep-all/blob/master/README.md Shows the help information specific to the underlying ripgrep utility. ```bash --rg-help ``` -------------------------------- ### CustomAdapterConfig Source: https://context7.com/phiresky/ripgrep-all/llms.txt Defines a custom adapter for ripgrep-all, specifying the binary to run, its arguments, and the file types it handles. This allows ripgrep-all to process files using external tools. ```APIDOC ## CustomAdapterConfig ### Description Struct that describes a subprocess-spawning adapter for use in the config file or Rust API. Each custom adapter specifies a binary to run, its arguments (with `$input_virtual_path`, `$input_file_stem`, and `$input_file_extension` placeholders), and the file extensions or MIME types it handles. The adapter pipes the input file to the binary's stdin and reads the output from stdout. ### Configuration Fields - **name** (string) - Required - A unique a-z0-9_ identifier for the adapter. - **version** (integer) - Required - Bump when output format changes to invalidate the cache. - **description** (string) - Required - A human-readable description of the adapter. - **extensions** (array of strings) - Optional - File extensions the adapter handles. - **mimetypes** (array of strings) - Optional - MIME types the adapter handles. - **match_only_by_mime** (boolean) - Optional - If true, extensions are ignored when `--rga-accurate` is used. Defaults to false. - **disabled_by_default** (boolean) - Optional - If true, the adapter is disabled by default. Defaults to false. - **binary** (string) - Required - The path to the binary to execute. - **args** (array of strings) - Required - Arguments to pass to the binary. Supports placeholders like `$input_virtual_path`, `$input_file_stem`, and `$input_file_extension`. - **output_path_hint** (string) - Optional - Controls what the next adapter sees as the filename. Defaults to `${input_virtual_path}.txt`. Can be set to another extension to chain adapters. ``` -------------------------------- ### `adapter_matcher` — File-to-Adapter Matching Source: https://context7.com/phiresky/ripgrep-all/llms.txt Builds a closure that maps `FileMeta` (filename + optional MIME type) to the best matching adapter. It compiles all adapter matchers into `RegexSet` instances for fast dispatch. When `slow = true` (accurate mode), MIME type matching takes precedence over extension matching. ```APIDOC ## `adapter_matcher` — File-to-Adapter Matching (Rust API) **Builds a closure that maps `FileMeta` (filename + optional MIME type) to the best matching adapter** Compiles all adapter matchers into `RegexSet` instances for fast dispatch. When `slow = true` (accurate mode), MIME type matching takes precedence over extension matching. ```rust use ripgrep_all::adapters::{get_all_adapters, get_adapters_filtered}; use ripgrep_all::matching::{adapter_matcher, FileMeta}; let (enabled, _disabled) = get_all_adapters(None); let adapters = get_adapters_filtered(None, &[])?; // Build a fast extension-only matcher (slow = false) let matcher = adapter_matcher(&adapters, false)?; // Match a PDF by extension let result = matcher(FileMeta { lossy_filename: "report.pdf".to_string(), mimetype: None, }); if let Some((adapter, reason)) = result { println!("Matched adapter: {}", adapter.metadata().name); println!("Match reason: {:?}", reason); } // Matched adapter: poppler // Match reason: Fast(FileExtension("pdf")) // Build an accurate MIME-type matcher (slow = true) let slow_matcher = adapter_matcher(&adapters, true)?; let result = slow_matcher(FileMeta { lossy_filename: "datafile", // no extension mimetype: Some("application/x-sqlite3"), }); if let Some((adapter, _)) = result { println!("MIME match: {}", adapter.metadata().name); } // MIME match: sqlite ``` ``` -------------------------------- ### Print Configuration Schema Source: https://github.com/phiresky/ripgrep-all/blob/master/README.md Outputs the JSON Schema for the rga configuration file, useful for validation and understanding configuration options. ```bash --rga-print-config-schema ``` -------------------------------- ### Print Version Information Source: https://github.com/phiresky/ripgrep-all/blob/master/README.md Displays the version of the ripgrep-all tool. ```bash -V ``` ```bash --version ``` -------------------------------- ### Basic Search with ripgrep-all Source: https://context7.com/phiresky/ripgrep-all/llms.txt Perform a basic search for a pattern across all supported file types in a directory tree. Options prefixed with --rga- are consumed by rga, while others are passed to ripgrep. ```bash # Search for "hello world" in every supported file under ./docs rga "hello world" ./docs ``` ```bash # Case-insensitive search (-i forwarded to rg), show 3 lines of context rga -i --context 3 "invoice" ~/Downloads ``` ```bash # Search only inside PDF and EPUB files (reduce scope) rga --rga-adapters=poppler,pandoc "chapter one" ~/books ``` ```bash # Disable caching (useful when debugging adapters) rga --rga-no-cache "TODO" ./project ``` ```bash # Use accurate MIME-based matching instead of file extension matching # Useful for SQLite files with unusual extensions (e.g. .db3, no extension) rga --rga-accurate "CREATE TABLE" ~/data ``` ```bash # Limit archive recursion to 2 levels deep (default is 5) rga --rga-max-archive-recursion=2 "secret" ./archives ``` ```bash # Do not prefix inner archive paths on matched lines rga --rga-no-prefix-filenames "error" ./logs.tar.gz ``` ```bash # Show only filenames that contain a match (--files-with-matches forwarded to rg) rga --files-with-matches "password" ~/backup.zip ``` ```bash # Use a custom config file path rga --rga-config-file=/etc/rga/config.jsonc "pattern" ./dir ``` ```bash # Enable all adapters including disabled-by-default ones (e.g. mail) rga --rga-adapters=+mail "From:" ~/mail.mbox ``` ```bash # Use all adapters EXCEPT pandoc and ffmpeg rga --rga-adapters=-pandoc,ffmpeg "keyword" ./docs ``` ```bash # Enable debug logging RUST_LOG=debug rga --rga-no-cache "test" ./exampledir 2>&1 ``` -------------------------------- ### Enable Debug Logging for ripgrep-all Source: https://github.com/phiresky/ripgrep-all/blob/master/README.md Set these environment variables to enable debug logging and backtraces for ripgrep-all. This is useful for diagnosing issues during development. ```bash export RUST_LOG=debug export RUST_BACKTRACE=1 ``` -------------------------------- ### Print ripgrep Version Source: https://github.com/phiresky/ripgrep-all/blob/master/README.md Shows the version of the underlying ripgrep utility. ```bash --rg-version ``` -------------------------------- ### Specify Cache Database Path Source: https://github.com/phiresky/ripgrep-all/blob/master/README.md Set a custom location for the rga cache database. ```bash --rga-cache-path= ``` -------------------------------- ### Inspect `rga-preproc` Output for a Zip Archive Source: https://context7.com/phiresky/ripgrep-all/llms.txt Examines the preprocessing of a zip archive using `rga-preproc`, which will recursively process its contents. ```bash # Inspect preprocessing of a zip archive (will recurse into contents) rga-preproc ./exampledir/demo/somearchive.zip ``` -------------------------------- ### Print Configuration Schema with rga Source: https://context7.com/phiresky/ripgrep-all/llms.txt Output the JSON Schema for the rga configuration file, which is useful for IDE auto-completion and validation. The schema can be redirected to a file for use with editors like VS Code. ```bash rga --rga-print-config-schema | python3 -m json.tool | head -60 ``` ```bash # Redirect to a schema file for VS Code IntelliSense rga --rga-print-config-schema > ~/.config/ripgrep-all/config.v1.schema.json ``` -------------------------------- ### Preprocess File with MIME Detection using `rga-preproc` Source: https://context7.com/phiresky/ripgrep-all/llms.txt Uses `rga-preproc` with the `--rga-accurate` flag to preprocess a file without an extension, relying on accurate MIME detection. ```bash # Preprocess a file with no extension using accurate MIME detection rga-preproc --rga-accurate ./exampledir/exampledir/sqlitedb ``` -------------------------------- ### Bash/Zsh fzf Integration for rga Source: https://github.com/phiresky/ripgrep-all/wiki/fzf-Integration Add this function to your ~/.bashrc or ~/.zshrc to enable interactive searching with fzf. It allows fuzzy finding files that match a query and opens the selected file. ```bash rga-fzf() { RG_PREFIX="rga --files-with-matches" local file file=( FZF_DEFAULT_COMMAND="$RG_PREFIX '$1'" \ fzf --sort --preview="[[ ! -z {} ]] && rga --pretty --context 5 {q} {}" \ --phony -q "$1" \ --bind "change:reload:$RG_PREFIX {q}" \ --preview-window="70%:wrap" ) && echo "opening $file" && xdg-open "$file" } ``` -------------------------------- ### Basic Usage of ripgrep-all Source: https://github.com/phiresky/ripgrep-all/blob/master/README.md The fundamental command structure for using rga, combining rga options with ripgrep's pattern and path arguments. ```bash rga [RGA OPTIONS] [RG OPTIONS] PATTERN [PATH ...] ``` -------------------------------- ### Bash/Zsh fzf Integration for Ripgrep-All Source: https://context7.com/phiresky/ripgrep-all/llms.txt Defines a bash function for integrating ripgrep-all with fzf, enabling custom preview options for search results. It sets up environment variables for fzf and uses rga for file searching and previewing. ```bash rga-fzf-manual() { local RG_PREFIX="rga --files-with-matches --rga-cache-max-blob-len=10M" local file file=( FZF_DEFAULT_COMMAND="$RG_PREFIX '$1'" \ fzf --preview="rga --pretty --context 5 {q} --rga-fzf-path=_{}" \ --preview-window=70%:wrap \ --phony --query "$1" --print-query \ --bind="change:reload:$RG_PREFIX {q}" ) echo "selected: $file" } rga-fzf-manual "search term" ``` -------------------------------- ### Fish Shell fzf Integration for rga Source: https://github.com/phiresky/ripgrep-all/wiki/fzf-Integration This function is for ~/.config/fish/config.fish to integrate rga with fzf. It supports passing arguments to rga and opens the selected file. ```fish function rga-fzf set RG_PREFIX 'rga --files-with-matches' if test (count $argv) -gt 1 set RG_PREFIX "$RG_PREFIX $argv[1..-2]" end set -l file $file set file ( FZF_DEFAULT_COMMAND="$RG_PREFIX '$argv[-1]'" \ fzf --sort \ --preview='test ! -z {} && \ rga --pretty --context 5 {q} {}' \ --phony -q "$argv[-1]" \ --bind "change:reload:$RG_PREFIX {q}" \ --preview-window='50%:wrap' ) && \ echo "opening $file" && \ open "$file" end ``` -------------------------------- ### `parse_args` / `split_args` — Configuration Parsing Source: https://context7.com/phiresky/ripgrep-all/llms.txt Merges CLI arguments, the `RGA_CONFIG` env var, and the config file into a single `RgaConfig`. `split_args` partitions `std::env::args_os()` into rga-owned args (prefixed `--rga-` or `--rg-`) and passthrough args forwarded to ripgrep. `parse_args` accepts an explicit iterator (useful for testing or embedding) and performs the three-way JSON merge. ```APIDOC ## `parse_args` / `split_args` — Configuration Parsing (Rust API) **Merges CLI arguments, the `RGA_CONFIG` env var, and the config file into a single `RgaConfig`** `split_args` partitions `std::env::args_os()` into rga-owned args (prefixed `--rga-` or `--rg-`) and passthrough args forwarded to ripgrep. `parse_args` accepts an explicit iterator (useful for testing or embedding) and performs the three-way JSON merge. ```rust use ripgrep_all::config::{parse_args, split_args}; // ── Embedded usage with explicit args ────────────────────────────────────── let config = parse_args( ["rga", "--rga-accurate", "--rga-no-cache", "--rga-max-archive-recursion=3"], false, // is_rga_preproc = false → also reads config file )?; assert!(config.accurate); assert!(config.cache.disabled); assert_eq!(config.max_archive_recursion.0, 3); // ── Typical use in the rga binary (reads from real env args) ────────────── let (rga_config, passthrough_args) = split_args(false)?; // rga_config → all --rga-* options, config file, and RGA_CONFIG merged // passthrough_args → everything else (PATTERN, PATH, -i, --context, etc.) println!("accurate: {}", rga_config.accurate); println!("cache path: {}", rga_config.cache.path); println!("rg args to forward: {:?}", passthrough_args); // ── Config priorities (low → high) ───────────────────────────────────────── // 1. ~/.config/ripgrep-all/config.jsonc (file, lowest priority) // 2. RGA_CONFIG env var (JSON string) // 3. CLI --rga-* arguments (highest priority) ``` ``` -------------------------------- ### `rga_preproc` — Core Preprocessing Function Source: https://context7.com/phiresky/ripgrep-all/llms.txt This is the central function in the preprocessing pipeline. It auto-selects an adapter by matching the file's extension (or MIME type if `config.accurate` is true), runs it, and wraps the output in a zstd-cached `AsyncRead` stream. Recursive archive entries are handled internally. ```APIDOC ## `rga_preproc` — Core Preprocessing Function (Rust API) **Selects and runs the appropriate adapter for an `AdaptInfo`, returning an `AsyncRead` of plain text** This is the central function in the preprocessing pipeline. It auto-selects an adapter by matching the file's extension (or MIME type if `config.accurate` is true), runs it, and wraps the output in a zstd-cached `AsyncRead` stream. Recursive archive entries are handled internally. ```rust use ripgrep_all::preproc::rga_preproc; use ripgrep_all::adapters::AdaptInfo; use ripgrep_all::config::RgaConfig; use tokio::fs::File; use tokio::io::AsyncReadExt; use std::path::PathBuf; #[tokio::main] async fn main() -> anyhow::Result<()> { let path = PathBuf::from("./exampledir/short.pdf"); let file = File::open(&path).await?; let config = RgaConfig { accurate: false, // use extension-based matching ..RgaConfig::default() }; let ai = AdaptInfo { filepath_hint: path.clone(), inp: Box::pin(file), is_real_file: true, archive_recursion_depth: 0, line_prefix: String::new(), postprocess: true, // prefix each line with "Page N: " config, }; let mut output = rga_preproc(ai).await?; let mut text = String::new(); output.read_to_string(&mut text).await?; println!("{text}"); // Page 1: hello world // Page 1: this is just a test. // Page 1: // Page 1: // 1 Ok(()) } ``` ``` -------------------------------- ### Search Video Subtitle Tracks with ripgrep-all Source: https://context7.com/phiresky/ripgrep-all/llms.txt Use the ffmpeg adapter to specifically search within video subtitle tracks. ```bash rga --rga-adapters=ffmpeg "previously on" ~/Videos ``` -------------------------------- ### Parse Configuration with parse_args and split_args (Rust API) Source: https://context7.com/phiresky/ripgrep-all/llms.txt Merge CLI arguments, `RGA_CONFIG` env var, and config file into `RgaConfig`. `split_args` separates rga-owned args from passthrough args for ripgrep. `parse_args` allows explicit argument iterators for testing. ```rust use ripgrep_all::config::{parse_args, split_args}; // ── Embedded usage with explicit args ────────────────────────────────────── let config = parse_args( ["rga", "--rga-accurate", "--rga-no-cache", "--rga-max-archive-recursion=3"], false, // is_rga_preproc = false → also reads config file )?; assert!(config.accurate); assert!(config.cache.disabled); assert_eq!(config.max_archive_recursion.0, 3); // ── Typical use in the rga binary (reads from real env args) ────────────── let (rga_config, passthrough_args) = split_args(false)?; // rga_config → all --rga-* options, config file, and RGA_CONFIG merged // passthrough_args → everything else (PATTERN, PATH, -i, --context, etc.) println!("accurate: {}", rga_config.accurate); println!("cache path: {}", rga_config.cache.path); println!("rg args to forward: {:?}", passthrough_args); // ── Config priorities (low → high) ───────────────────────────────────────── // 1. ~/.config/ripgrep-all/config.jsonc (file, lowest priority) // 2. RGA_CONFIG env var (JSON string) // 3. CLI --rga-* arguments (highest priority) ``` -------------------------------- ### Set Maximum Blob Size for Caching Source: https://github.com/phiresky/ripgrep-all/blob/master/README.md Define the maximum compressed size for adapter outputs to be stored in the cache. Larger outputs will not be cached. ```bash --rga-cache-max-blob-len= ``` -------------------------------- ### Set Zstd Compression Level for ripgrep-all Cache Source: https://context7.com/phiresky/ripgrep-all/llms.txt Adjust the Zstandard compression level for the cache. Higher levels result in a smaller cache but slower write times, while lower levels result in a larger cache but faster write times. ```bash rga --rga-cache-compression-level=22 "term" ./books ``` ```bash rga --rga-cache-compression-level=1 "term" ./books ``` -------------------------------- ### Search SQLite Databases with ripgrep-all Source: https://context7.com/phiresky/ripgrep-all/llms.txt Search SQLite databases using the sqlite adapter, without relying on file extensions. This command also enables accurate MIME-sniffing. ```bash rga --rga-accurate --rga-adapters=sqlite "INSERT INTO users" ~/data ``` -------------------------------- ### Windows Batch Script fzf Integration for rga Source: https://github.com/phiresky/ripgrep-all/wiki/fzf-Integration A batch script for Windows to achieve similar functionality to the Unix-like shells. Place this script in your %PATH% for easy access. ```bat @echo off setlocal set RG_PREFIX=rga --files-with-matches set FZF_DEFAULT_COMMAND=%RG_PREFIX% %1 for /f "delims=" %%i in ('fzf --sort --preview "rga --pretty --context 5 {q} {}" --phony -q %1 --bind "change:reload:%RG_PREFIX% {q}" --preview-window="70%:wrap"') do ( set FILE=%%i ) if not "%FILE%" == "" ( echo Opening %FILE% start "" "%FILE%" ) else ( echo No file selected. ) endlocal ``` -------------------------------- ### Inspect `rga-preproc` Output for a PDF Source: https://context7.com/phiresky/ripgrep-all/llms.txt Uses `rga-preproc` to inspect the preprocessing output for a specific file, useful for debugging adapter behavior. ```bash # Inspect what rga-preproc produces for a PDF rga-preproc ./exampledir/short.pdf ``` -------------------------------- ### Override Configuration with `RGA_CONFIG` Environment Variable Source: https://context7.com/phiresky/ripgrep-all/llms.txt Supplements or overrides the `config.jsonc` file using a JSON string in the environment. Merged on top of file config but below CLI arguments. ```bash # Disable cache for a one-off search via environment RGA_CONFIG='{"cache":{"disabled":true}}' rga "TODO" ./src ``` ```bash # Force accurate mode and limit recursion via env RGA_CONFIG='{"accurate":true,"max_archive_recursion":3}' rga "error" ./logs ``` ```bash # Enable the mail adapter via env without changing config file RGA_CONFIG='{"adapters":"+mail"}' rga "Re:" ~/Maildir ``` -------------------------------- ### Enable Accurate Matching by Mime Type Source: https://github.com/phiresky/ripgrep-all/blob/master/README.md This flag enables more precise file type detection using magic bytes, which can be slower but more accurate than relying on file extensions. ```bash --rga-accurate ``` -------------------------------- ### Set Cache Compression Level Source: https://github.com/phiresky/ripgrep-all/blob/master/README.md Adjust the ZSTD compression level for adapter outputs stored in the cache. Higher levels mean more compression but potentially slower processing. ```bash --rga-cache-compression-level= ``` -------------------------------- ### Limit Cache Entries Size in ripgrep-all Source: https://context7.com/phiresky/ripgrep-all/llms.txt Set a maximum size for cached blobs, useful for excluding large files like PDFs from the cache. ```bash rga --rga-cache-max-blob-len=500k "keyword" ./archive ``` -------------------------------- ### get_adapters_filtered Source: https://context7.com/phiresky/ripgrep-all/llms.txt Programmatically filters the full adapter list based on a user-supplied selector string. This Rust API function allows for dynamic selection of adapters, including custom ones. ```APIDOC ## get_adapters_filtered ### Description Filters the full adapter list according to a user-supplied selector string. Returns an ordered `Vec>` based on the selector rules: plain names mean "use only these", a leading `-` means "exclude from defaults", a leading `+` means "add to defaults with higher priority". Custom adapter configs are merged before filtering. ### Parameters - **custom_adapters** (Option>) - Optional - A vector of `CustomAdapterConfig` structs to include. - **selectors** (slice of strings) - Required - A slice of strings used to filter adapters. Examples: - `"poppler"`: Use only the poppler adapter. - `"-ffmpeg"`: Use all default adapters except ffmpeg. - `"+mail"`: Add the mail adapter to the defaults with higher priority. ### Returns - `Result>, Error>` - An ordered vector of selected file adapters or an error. ### Example (Rust) ```rust use ripgrep_all::adapters::{get_adapters_filtered, CustomAdapterConfig}; // Use only the poppler (PDF) and sqlite adapters let adapters = get_adapters_filtered(None, &["poppler", "sqlite"])?; println!("Selected: {:?}", adapters.iter().map(|a| &a.metadata().name).collect::>()); // Selected: ["poppler", "sqlite"] // Use all default adapters except ffmpeg let adapters = get_adapters_filtered(None, &["-ffmpeg"])?; // Add the mail adapter on top of all defaults (highest priority) let adapters = get_adapters_filtered(None, &["+mail"])?; // Include a custom adapter config alongside defaults let custom = vec![CustomAdapterConfig { name: "my_converter".to_string(), version: 1, description: "Custom text extractor".to_string(), extensions: vec!["myext".to_string()], mimetypes: None, match_only_by_mime: None, binary: "/usr/local/bin/myconverter".to_string(), args: vec!["$input_virtual_path".to_string()], disabled_by_default: Some(false), output_path_hint: None, }]; let adapters = get_adapters_filtered(Some(custom), &[])?; ``` ``` -------------------------------- ### JSON Schema Mimetypes Definition Source: https://github.com/phiresky/ripgrep-all/blob/master/doc/notes.md This JSON schema snippet defines the 'mimetypes' property. When not null and the '--rga-accurate' flag is enabled, it specifies that MIME type matching will be used instead of file name matching. The property can be an array of strings or null. ```json "mimetypes": { "description": "if not null and --rga-accurate is enabled, mime type matching is used instead of file name matching", "type": [ "array", "null" ], "items": { "type": "string" } }, ``` -------------------------------- ### Disable Cache for a ripgrep-all Run Source: https://context7.com/phiresky/ripgrep-all/llms.txt Completely disable the cache for a specific command execution. ```bash rga --rga-no-cache "debug query" ./src ``` -------------------------------- ### Recursively Search Nested Archives with ripgrep-all Source: https://context7.com/phiresky/ripgrep-all/llms.txt Search for a pattern within a deeply nested archive file (e.g., a .tar.gz containing a .zip which contains a .pdf). rga automatically handles decompression and extraction. ```bash rga "needle" ./haystack.tar.gz ``` -------------------------------- ### Clear ripgrep-all Cache Manually Source: https://context7.com/phiresky/ripgrep-all/llms.txt Manually remove the ripgrep-all cache directory. This command is for Linux systems. ```bash rm -rf ~/.cache/ripgrep-all ``` -------------------------------- ### Set Maximum Archive Recursion Depth Source: https://github.com/phiresky/ripgrep-all/blob/master/README.md Limit how many levels deep rga will recurse into nested archives. ```bash --rga-max-archive-recursion= ``` -------------------------------- ### Disable Caching Source: https://github.com/phiresky/ripgrep-all/blob/master/README.md Use this flag to prevent rga from caching extracted text, ensuring that all content is re-processed on each search. ```bash --rga-no-cache ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.