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
parent 415be382ca
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

@ -2,18 +2,32 @@
This plugin enables [junegunn's fzf](https://github.com/junegunn/fzf) fuzzy auto-completion and key bindings This plugin enables [junegunn's fzf](https://github.com/junegunn/fzf) fuzzy auto-completion and key bindings
To use it, add `fzf` to the plugins array in your zshrc file:
```zsh
plugins=(... fzf)
```
## Settings
Add these before the `plugins=()` line in your zshrc file:
```zsh ```zsh
# Set fzf installation directory path # Set fzf installation directory path
export FZF_BASE=/path/to/fzf/install/dir # export FZF_BASE=/path/to/fzf/install/dir
# Uncomment to set the FZF_DEFAULT_COMMAND
# export FZF_DEFAULT_COMMAND='<your fzf default commmand>'
# Uncomment the following line to disable fuzzy completion # Uncomment the following line to disable fuzzy completion
# export DISABLE_FZF_AUTO_COMPLETION="true" # DISABLE_FZF_AUTO_COMPLETION="true"
# Uncomment the following line to disable key bindings (CTRL-T, CTRL-R, ALT-C) # Uncomment the following line to disable key bindings (CTRL-T, CTRL-R, ALT-C)
# export DISABLE_FZF_KEY_BINDINGS="true" # DISABLE_FZF_KEY_BINDINGS="true"
plugins=(
...
fzf
)
``` ```
| Setting | Example value | Description |
|-----------------------------|----------------------------|-------------------------------------------------------------|
| FZF_BASE | `/path/to/fzf/install/dir` | Set fzf installation directory path (**export**) |
| FZF_DEFAULT_COMMAND | `fd --type f` | Set default command to use when input is tty (**export**) |
| DISABLE_FZF_AUTO_COMPLETION | `true` | Set whether to load fzf auto-completion |
| DISABLE_FZF_KEY_BINDINGS | `true` | Set whether to disable key bindings (CTRL-T, CTRL-R, ALT-C) |

View file

@ -98,3 +98,13 @@ function indicate_error() {
setup_using_debian_package || setup_using_base_dir || indicate_error setup_using_debian_package || setup_using_base_dir || indicate_error
unset -f 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