Skip to content

Instantly share code, notes, and snippets.

@evgenii-malov
Created December 17, 2022 16:14
Show Gist options
  • Save evgenii-malov/1ca30049f3396295f9a00d02ca4823b2 to your computer and use it in GitHub Desktop.
Save evgenii-malov/1ca30049f3396295f9a00d02ca4823b2 to your computer and use it in GitHub Desktop.
fzf search in files with open is visual studio code (ctrl-o)
fif() {
rg \
--column \
--no-heading \
--fixed-strings \
--ignore-case \
--hidden \
--follow \
--glob '!.git/*' \
--glob '!.vscode-server/*' \
"$1" \
| awk -F ":" '/1/ {start = $2<5 ? 0 : $2 - 5; end = $2 + 5; print $1 " " $2 " " $3 " " start ":" end}' \
| fzf \
--bind 'ctrl-o:execute(code --goto {1}:{2}:{3})+cancel' \
--preview 'batcat --wrap character --color always {1} --highlight-line {2} --line-range {4}' \
--preview-window wrap
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment