Skip to content

Instantly share code, notes, and snippets.

@emjayoh
Forked from gnanderson/fif.sh
Last active November 18, 2020 15:15
Show Gist options
  • Save emjayoh/12cfaa1ceeeaace3a1dcb1e7b9f4289a to your computer and use it in GitHub Desktop.
Save emjayoh/12cfaa1ceeeaace3a1dcb1e7b9f4289a to your computer and use it in GitHub Desktop.
[fif.sh - fuzzy + rg + bat] Find in file using ripgrep, then fuzzy find matched filenames with fzf, preview match using bat #fzf #terminal #bash #shell #bat #rg #function
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