diff --git a/fish/functions/rfv.fish b/fish/functions/rfv.fish new file mode 100644 index 0000000..b05c8f3 --- /dev/null +++ b/fish/functions/rfv.fish @@ -0,0 +1,20 @@ +# ripgrep->fzf->nvim [QUERY] +# Ripped from: https://junegunn.github.io/fzf/tips/ripgrep-integration/ +function rfv + set -lx RELOAD 'reload:rg --column --color=always --smart-case {q} || :' + set -lx OPENER 'if [[ $FZF_SELECT_COUNT -eq 0 ]]; then + nvim {1} +{2} # No selection. Open the current line in Vim. + else + nvim +cw -q {+f} # Build quickfix list for the selected items. + fi' + fzf < /dev/null \ + --disabled --ansi --multi \ + --bind "start:$RELOAD" --bind "change:$RELOAD" \ + --bind "enter:become:$OPENER" \ + --bind "ctrl-o:execute:$OPENER" \ + --bind 'alt-a:select-all,alt-d:deselect-all,ctrl-/:toggle-preview' \ + --delimiter : \ + --preview 'bat --style=full --color=always --highlight-line {2} {1}' \ + --preview-window '~4,+{2}+4/3,<80(up)' \ + --query "$argv" +end