[bash] Revert skipping setting up fuzzy path completion

This partially reverts a2d0e8f not to break backward compatibility.
This commit is contained in:
Junegunn Choi
2024-08-22 19:39:22 +09:00
parent 8cb59e6fca
commit cf2242aea3

View File

@@ -496,19 +496,22 @@ __fzf_default_completion() {
fi fi
} }
if complete | command grep -q __fzf_default_completion; then # Set fuzzy path completion as the default completion for all commands.
: # Default completion already set up. Do nothing. # We can't set up default completion,
elif ! complete | command grep -- '-D$' | command grep -qv _comp_complete_load && # 1. if it's already set up by another script
complete -D -F __fzf_default_completion -o default -o bashdefault 2> /dev/null; then # 2. or if the current version of bash doesn't support -D option
a_cmds="" complete | command grep -q __fzf_default_completion ||
else complete | command grep -- '-D$' | command grep -qv _comp_complete_load ||
# We can't set up default completion, complete -D -F __fzf_default_completion -o default -o bashdefault 2> /dev/null
# 1. if it's already set up by another script
# 2. or if the current version of bash doesn't support -D option d_cmds="${FZF_COMPLETION_DIR_COMMANDS-cd pushd rmdir}"
#
# NOTE: $FZF_COMPLETION_PATH_COMMANDS and $FZF_COMPLETION_VAR_COMMANDS are # NOTE: $FZF_COMPLETION_PATH_COMMANDS and $FZF_COMPLETION_VAR_COMMANDS are
# undocumented and subject to change in the future. # undocumented and subject to change in the future.
a_cmds="${FZF_COMPLETION_PATH_COMMANDS-" #
# NOTE: Although we have default completion, we still need to set up completion
# for each command in case they already have completion set up by another script.
a_cmds="${FZF_COMPLETION_PATH_COMMANDS-"
awk bat cat code diff diff3 awk bat cat code diff diff3
emacs emacsclient ex file ftp g++ gcc gvim head hg hx java emacs emacsclient ex file ftp g++ gcc gvim head hg hx java
javac ld less more mvim nvim patch perl python ruby javac ld less more mvim nvim patch perl python ruby
@@ -517,10 +520,6 @@ else
find git grep gunzip gzip hg jar find git grep gunzip gzip hg jar
ln ls mv open rm rsync scp ln ls mv open rm rsync scp
svn tar unzip zip"}" svn tar unzip zip"}"
fi
d_cmds="${FZF_COMPLETION_DIR_COMMANDS-cd pushd rmdir}"
v_cmds="${FZF_COMPLETION_VAR_COMMANDS-export unset printenv}" v_cmds="${FZF_COMPLETION_VAR_COMMANDS-export unset printenv}"
# Preserve existing completion # Preserve existing completion