Fix fzf's ssh host completion under failglob in bash
fzf's completion.bash globs ~/.ssh/config.d/* when listing hosts => With `shopt -s failglob`, a missing or empty folder makes this an expansion error, printing "bash: no match" on every <Tab> after `ssh` Define __fzf_list_hosts before sourcing fzf, using its override hook with bash-completion's host list, as fzf itself suggests
This commit is contained in:
parent
ab78875746
commit
7cf5654a4b
1 changed files with 11 additions and 0 deletions
|
|
@ -16,6 +16,17 @@ complete -W '--quieter' generate-shell-completions
|
||||||
#
|
#
|
||||||
# Must be sourced before `complete_alias` below,
|
# Must be sourced before `complete_alias` below,
|
||||||
# which then saves fzf's wrappers as the vanilla completions
|
# which then saves fzf's wrappers as the vanilla completions
|
||||||
|
#
|
||||||
|
# fzf's own host list globs ~/.ssh/config.d/*,
|
||||||
|
# which aborts under `failglob` if that folder is empty or missing
|
||||||
|
# => Use fzf's override hook with `bash-completion`'s host list instead
|
||||||
|
|
||||||
|
__fzf_list_hosts() {
|
||||||
|
local COMPREPLY=()
|
||||||
|
_known_hosts_real ''
|
||||||
|
printf '%s\n' "${COMPREPLY[@]}" | command sort -u --version-sort
|
||||||
|
}
|
||||||
|
|
||||||
if [ -r /usr/share/doc/fzf/examples/completion.bash ]; then
|
if [ -r /usr/share/doc/fzf/examples/completion.bash ]; then
|
||||||
. /usr/share/doc/fzf/examples/completion.bash
|
. /usr/share/doc/fzf/examples/completion.bash
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue