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 <junegunn.c@gmail.com>
main
Mathieu Lemay 2 years ago committed by GitHub
parent bfcd68d3b4
commit f31e8a07b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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' \

Loading…
Cancel
Save