From c9026eb8429c38f0d76c1b8a26ba22aa8cf7e949 Mon Sep 17 00:00:00 2001 From: qwjyh Date: Wed, 26 Feb 2025 19:36:07 +0900 Subject: [PATCH] new(fish): add rga fzf integrated func https://github.com/phiresky/ripgrep-all/blob/c97fa3a491f37a782fdcf95b505b56c866121006/README.md --- dotfiles/fish/config.fish | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/dotfiles/fish/config.fish b/dotfiles/fish/config.fish index 37148a4..f549acb 100644 --- a/dotfiles/fish/config.fish +++ b/dotfiles/fish/config.fish @@ -24,6 +24,25 @@ if status is-interactive # opam #source ~/.opam/opam-init/init.fish > /dev/null 2> /dev/null; or true + + function rga-fzf + set RG_PREFIX 'rga --files-with-matches' + if test (count $argv) -gt 1 + set RG_PREFIX "$RG_PREFIX $argv[1..-2]" + end + set -l file $file + set file ( + FZF_DEFAULT_COMMAND="$RG_PREFIX '$argv[-1]'" \ + fzf --sort \ + --preview='test ! -z {} && \ + rga --pretty --context 5 {q} {}' \ + --phony -q "$argv[-1]" \ + --bind "change:reload:$RG_PREFIX {q}" \ + --preview-window='50%:wrap' + ) && \ + echo "opening $file" && \ + open "$file" + end end # starship