zsh: Add $fzf_default_no_rg
Move the fallback for $FZF_DEFAULT_COMMAND into the variable fzf_default_no_rg that is always set. This way FZF_ALT_C_COMMAND can reuse it instead of spawning a new shell and messing with PATH.
This commit is contained in:
@@ -90,18 +90,20 @@ LESS+="${LESS:+ }--RAW-CONTROL-CHARS"
|
|||||||
LESS+="${LESS:+ }--quit-if-one-screen"
|
LESS+="${LESS:+ }--quit-if-one-screen"
|
||||||
export LESS
|
export LESS
|
||||||
|
|
||||||
|
# NOTE: This is used in keys.zsh for the ALT_C widget
|
||||||
|
fzf_default_no_rg="find -L . -mindepth 1 \("
|
||||||
|
fzf_default_no_rg+=" -name '.git' -o"
|
||||||
|
fzf_default_no_rg+=" -name '__pycache__' -o"
|
||||||
|
fzf_default_no_rg+=" -name 'node_modules'"
|
||||||
|
fzf_default_no_rg+=" \) -prune -o -type f -print"
|
||||||
|
fzf_default_no_rg+=" | cut -c3-"
|
||||||
|
|
||||||
if (( $+commands[rg] )); then
|
if (( $+commands[rg] )); then
|
||||||
# Prune `.git/` and everything ignored by gitignore(5)
|
# Prune `.git/` and everything ignored by gitignore(5)
|
||||||
FZF_DEFAULT_COMMAND="rg -L --hidden --files -g '!.git'"
|
FZF_DEFAULT_COMMAND="rg -L --hidden --files -g '!.git'"
|
||||||
else
|
else
|
||||||
# Fallback to hardcoding the most important paths to prune
|
# 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="$fzf_default_no_rg"
|
||||||
FZF_DEFAULT_COMMAND="find -L . -mindepth 1 \("
|
|
||||||
FZF_DEFAULT_COMMAND+=" -name '.git' -o"
|
|
||||||
FZF_DEFAULT_COMMAND+=" -name '__pycache__' -o"
|
|
||||||
FZF_DEFAULT_COMMAND+=" -name 'node_modules'"
|
|
||||||
FZF_DEFAULT_COMMAND+=" \) -prune -o -type f -print"
|
|
||||||
FZF_DEFAULT_COMMAND+=" | cut -c3-"
|
|
||||||
fi
|
fi
|
||||||
export FZF_DEFAULT_COMMAND
|
export FZF_DEFAULT_COMMAND
|
||||||
|
|
||||||
|
|||||||
@@ -140,8 +140,5 @@ bindkey -M vicmd '^K' fzf-history-widget
|
|||||||
FZF_CTRL_T_COMMAND="${FZF_DEFAULT_COMMAND}"
|
FZF_CTRL_T_COMMAND="${FZF_DEFAULT_COMMAND}"
|
||||||
# Use the fallback default command when ripgrep is not installed but with
|
# Use the fallback default command when ripgrep is not installed but with
|
||||||
# directories instead of files.
|
# directories instead of files.
|
||||||
FZF_ALT_C_COMMAND="$(
|
FZF_ALT_C_COMMAND="${fzf_default_no_rg/-type f/-type d}"
|
||||||
zsh -c 'path= . "$ZDOTDIR/.zprofile"; echo "$FZF_DEFAULT_COMMAND"' \
|
|
||||||
| sed 's/-type f/-type d/'
|
|
||||||
)"
|
|
||||||
comp-source "$ZDOTDIR/plugins/fzf/shell/key-bindings.zsh"
|
comp-source "$ZDOTDIR/plugins/fzf/shell/key-bindings.zsh"
|
||||||
|
|||||||
Reference in New Issue
Block a user