-
-
Save seanf/8513254ab4cb097c759e69b3d6793fc8 to your computer and use it in GitHub Desktop.
Using fzf as interactive Ripgrep launcher
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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