Skip to content
Myr

[bash-completion] Add _fzf_setup_completion to enable fuzzy completion

Before adoption: this commit came in with the history the project adopted, so no landing records it.

While we can attach `_fzf_path_completion` or `_fzf_dir_completion` to any command using the standard bash complete command, the functionality of the existing completion function is lost. Use _fzf_setup_completion if you want to extend the existing function with fuzzy completion instead of completely replacing it. e.g. _fzf_setup_completion path kubectl

authored by Junegunn Choi · committed by Junegunn Choi · parent 4800e5d · Browse files · 1 file+14 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+14 added−0 removed

  • other:+14 added−0 removed

1 file+14 added−0 removed

modified:shell/completion.bash+14 added
331 unmodified lines
332complete -F _fzf_complete_unalias -o default -o bashdefault unalias333334unset cmd d_cmds a_cmds x_cmds335336_fzf_setup_completion() {337 local fn cmd338 if [[ $# -lt 2 ]] || ! type -t _fzf_${1}_completion > /dev/null; then339 echo "usage: ${FUNCNAME[0]} path|dir COMMANDS..."340 return 1341 fi342 fn=_fzf_${1}_completion343 shift344 for cmd in "$@"; do345 eval "$(complete -p "$cmd" 2> /dev/null | grep -v "$fn" | __fzf_orig_completion_filter)"346 complete -F "$fn" -o default -o bashdefault "$cmd"347 done348}349350fi