Skip to content

Instantly share code, notes, and snippets.

@seanf
Created May 30, 2025 12:38
Show Gist options
  • Save seanf/8513254ab4cb097c759e69b3d6793fc8 to your computer and use it in GitHub Desktop.
Save seanf/8513254ab4cb097c759e69b3d6793fc8 to your computer and use it in GitHub Desktop.
Using fzf as interactive Ripgrep launcher
#!/usr/bin/env bash
# https://github.com/junegunn/fzf/blob/master/ADVANCED.md#using-fzf-as-interactive-ripgrep-launcher
# 1. Search for text in files using Ripgrep
# 2. Interactively restart Ripgrep with reload action
# 3. Open the file in Vim^W Micro
RG_PREFIX="rg --column --line-number --no-heading --color=always --smart-case "
INITIAL_QUERY="${*:-}"
fzf --ansi --disabled --query "$INITIAL_QUERY" \
--bind "start:reload:$RG_PREFIX {q}" \
--bind "change:reload:sleep 0.1; $RG_PREFIX {q} || true" \
--delimiter : \
--preview 'bat --color=always {1} --highlight-line {2}' \
--preview-window 'up,60%,border-bottom,+{2}+3/3,~3' \
--bind 'enter:become(micro {1} +{2})'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment