diff options
| author | Junegunn Choi <junegunn.c@gmail.com> | 2019-08-08 15:35:52 +0900 |
|---|---|---|
| committer | Junegunn Choi <junegunn.c@gmail.com> | 2019-08-08 15:35:52 +0900 |
| commit | 50958992455708f4a9ec82f745f7496fbca243c7 (patch) | |
| tree | 6970b8aaf391d500f751ba1868d80044e693a973 /shell/completion.bash | |
| parent | 4800e5d2ae6bac335dbc9fb1aae493761f4d70ee (diff) | |
| download | fzf-50958992455708f4a9ec82f745f7496fbca243c7.tar.gz | |
[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
Diffstat (limited to 'shell/completion.bash')
| -rw-r--r-- | shell/completion.bash | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/shell/completion.bash b/shell/completion.bash index 29648297..1bedb43e 100644 --- a/shell/completion.bash +++ b/shell/completion.bash @@ -333,4 +333,18 @@ complete -F _fzf_complete_unalias -o default -o bashdefault unalias 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 |
