Skip to content

Instantly share code, notes, and snippets.

@lijie2000
Forked from gnanderson/fif.sh
Created November 3, 2023 15:30
Show Gist options
  • Save lijie2000/d527602e3e9544213ac5ac408b3bec20 to your computer and use it in GitHub Desktop.
Save lijie2000/d527602e3e9544213ac5ac408b3bec20 to your computer and use it in GitHub Desktop.
Find in file using ripgrep, then fuzzy find matched filenames with fzf, preview match using bat
fif() {
rg \
--column \
--line-number \
--no-column \
--no-heading \
--fixed-strings \
--ignore-case \
--hidden \
--follow \
--glob '!.git/*' "$1" \
| awk -F ":" '/1/ {start = $2<5 ? 0 : $2 - 5; end = $2 + 5; print $1 " " $2 " " start ":" end}' \
| fzf --preview 'bat --wrap character --color always {1} --highlight-line {2} --line-range {3}' --preview-window wrap
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment