From fb9f3b83a430ce1e8ecbf93464fbb98e364c6934 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Wed, 25 Nov 2020 11:36:21 +0100 Subject: [PATCH] sh: Add fuzzy ripgrep-all search Added function to fuzzily search through any documents using rga. Function code adapted from https://github.com/phiresky/ripgrep-all Can be interactively searched, should be reasonably fast once indexing is finished. --- sh/.config/sh/alias | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/sh/.config/sh/alias b/sh/.config/sh/alias index 55b4d9f..0c5c140 100644 --- a/sh/.config/sh/alias +++ b/sh/.config/sh/alias @@ -53,6 +53,20 @@ if exist fzf; then # Fuzzy uninstall packages alias fzfyayrns="yay -Qeq | fzf -m --preview 'yay -Qi {1}' | xargs -ro yay -Rns" fi + + # ripgrep-all to fzf search through any documents + if exist rga; then + rgafzf() { + RG_PREFIX="rga --files-with-matches" + xdg-open "$( + FZF_DEFAULT_COMMAND="$RG_PREFIX '$1'" \ + fzf --sort --preview="[[ ! -z {} ]] && rga --pretty --context 5 {q} {}" \ + --phony -q "$1" \ + --bind "change:reload:$RG_PREFIX {q}" \ + --preview-window="70%:wrap" + )" + } + fi fi # vifm