mirror of
https://github.com/junegunn/fzf
synced 2024-11-01 03:20:42 +00:00
[bash-completion] Add _fzf_setup_completion to enable fuzzy completion
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
This commit is contained in:
parent
4800e5d2ae
commit
5095899245
@ -333,4 +333,18 @@ complete -F _fzf_complete_unalias -o default -o bashdefault unalias
|
|||||||
|
|
||||||
unset cmd d_cmds a_cmds x_cmds
|
unset cmd d_cmds a_cmds x_cmds
|
||||||
|
|
||||||
|
_fzf_setup_completion() {
|
||||||
|
local fn cmd
|
||||||
|
if [[ $# -lt 2 ]] || ! type -t _fzf_${1}_completion > /dev/null; then
|
||||||
|
echo "usage: ${FUNCNAME[0]} path|dir COMMANDS..."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
fn=_fzf_${1}_completion
|
||||||
|
shift
|
||||||
|
for cmd in "$@"; do
|
||||||
|
eval "$(complete -p "$cmd" 2> /dev/null | grep -v "$fn" | __fzf_orig_completion_filter)"
|
||||||
|
complete -F "$fn" -o default -o bashdefault "$cmd"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user