zsh:keys: Reuse the default fallback for FZF_ALT_C
Instead of implementing it twice, simulate a shell without ripgrep to get the fallback of FZF_DEFAULT_COMMAND and modify it for use with directories.
This commit is contained in:
@@ -95,6 +95,7 @@ if (( $+commands[rg] )); then
|
||||
FZF_DEFAULT_COMMAND="rg -L --hidden --files -g '!.git'"
|
||||
else
|
||||
# Fallback to hardcoding the most important paths to prune
|
||||
# NOTE: This version is used in keys.zsh for the ALT_C widget
|
||||
FZF_DEFAULT_COMMAND="find -L . \("
|
||||
FZF_DEFAULT_COMMAND+=" -name '.git' -o"
|
||||
FZF_DEFAULT_COMMAND+=" -name '__pycache__' -o"
|
||||
|
||||
@@ -138,9 +138,10 @@ bindkey -M vicmd '^K' fzf-history-widget
|
||||
# \ec (Alt-C) fzf-cd-widget
|
||||
# ^R fzf-history-widget
|
||||
FZF_CTRL_T_COMMAND="${FZF_DEFAULT_COMMAND}"
|
||||
FZF_ALT_C_COMMAND="find -L . -mindepth 1 \("
|
||||
FZF_ALT_C_COMMAND+=" -name '.git' -o"
|
||||
FZF_ALT_C_COMMAND+=" -name '__pycache__' -o"
|
||||
FZF_ALT_C_COMMAND+=" -name 'node_modules'"
|
||||
FZF_ALT_C_COMMAND+=" \) -prune -o -type d -print"
|
||||
# Use the fallback default command when ripgrep is not installed but with
|
||||
# directories instead of files.
|
||||
FZF_ALT_C_COMMAND="$(
|
||||
zsh -c 'path= . "$ZDOTDIR/.zprofile"; echo "$FZF_DEFAULT_COMMAND"' \
|
||||
| sed 's/-type f/-type d/'
|
||||
)"
|
||||
comp-source "$ZDOTDIR/plugins/fzf/shell/key-bindings.zsh"
|
||||
|
||||
Reference in New Issue
Block a user