From 442c1af1a8bc9c6f2e0f6e5f80f05a803a24607a Mon Sep 17 00:00:00 2001 From: Damien Dart Date: Wed, 17 Jul 2024 23:37:42 +0100 Subject: [PATCH] "fuzzy-grep": Improve handling of empty queries. --- bin/fuzzy-grep | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/bin/fuzzy-grep b/bin/fuzzy-grep index a90c8e0..3f087a9 100755 --- a/bin/fuzzy-grep +++ b/bin/fuzzy-grep @@ -109,14 +109,18 @@ INITIAL_QUERY="${*:-}" export INPUT_TRANSFORM=' RELOAD_BASE="reload:rg --color=always --column --hidden --line-number --smart-case %s -- \{q} || true" - case "$FZF_PROMPT" in - *★*) - printf "$RELOAD_BASE" "--no-ignore" - ;; - *) - printf "$RELOAD_BASE" "--glob=\"!.git/\"" - ;; - esac + if [[ "$FZF_QUERY" == "" ]]; then + echo "reload:true" + else + case "$FZF_PROMPT" in + *★*) + printf "$RELOAD_BASE" "--no-ignore" + ;; + *) + printf "$RELOAD_BASE" "--glob=\"!.git/\"" + ;; + esac + fi ' # shellcheck disable=SC2016