From f31e8a07b58b8f0033d68f9ac791a6df9ceafbc0 Mon Sep 17 00:00:00 2001 From: Mathieu Lemay Date: Tue, 30 Aug 2022 20:08:55 -0400 Subject: [PATCH] Fix _fzf_git_files not showing anything in clean repo on macOS (#9) On both Linux and macOS, `grep -f` will match nothing when provided with an empty file. However, unlike on Linux, when combined with `-v`, grep on macOS 10 will not match everything when provided with an empty file while the `-v` flag is active. This results in `_fzf_git_files` being empty when in a clean repository. This fixes this behavior by making the file non-empty by printing `:`. Co-authored-by: Junegunn Choi --- fzf-git.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fzf-git.sh b/fzf-git.sh index 855d7fb..5bd2335 100644 --- a/fzf-git.sh +++ b/fzf-git.sh @@ -133,7 +133,7 @@ fi _fzf_git_files() { _fzf_git_check || return (git -c color.status=always status --short - git ls-files | grep -vf <(git status -s | grep '^[^?]' | cut -c4-) | sed 's/^/ /') | + git ls-files | grep -vxFf <(git status -s | grep '^[^?]' | cut -c4-; echo :) | sed 's/^/ /') | _fzf_git_fzf -m --ansi --nth 2..,.. \ --prompt '📁 Files> ' \ --header $'CTRL-O (open in browser) ╱ ALT-E (open in editor)\n\n' \