fzf: setup FZF_DEFAULT_COMMAND based on installed tools (#8895)

Co-authored-by: Marc Cornellà <marc.cornella@live.com>
This commit is contained in:
Alessandro Martini 2020-09-04 17:13:45 -03:00 committed by GitHub
commit 708ea42384
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 8 deletions

View file

@ -98,3 +98,13 @@ function indicate_error() {
setup_using_debian_package || setup_using_base_dir || indicate_error
unset -f setup_using_debian_package setup_using_base_dir indicate_error
if [[ -z "$FZF_DEFAULT_COMMAND" ]]; then
if (( $+commands[rg] )); then
export FZF_DEFAULT_COMMAND='rg --files --hidden'
elif (( $+commands[fd] )); then
export FZF_DEFAULT_COMMAND='fd --type f --hidden --exclude .git'
elif (( $+commands[ag] )); then
export FZF_DEFAULT_COMMAND='ag -l --hidden -g ""'
fi
fi