From 7cf5654a4b0ad3313487f650e2e9c3aa4a975b2a Mon Sep 17 00:00:00 2001 From: Alexander Hess Date: Tue, 6 Oct 2026 13:36:07 +0200 Subject: [PATCH] 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 after `ssh` Define __fzf_list_hosts before sourcing fzf, using its override hook with bash-completion's host list, as fzf itself suggests --- .bash_completion | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.bash_completion b/.bash_completion index 5fb1dac..77d8cbd 100644 --- a/.bash_completion +++ b/.bash_completion @@ -16,6 +16,17 @@ complete -W '--quieter' generate-shell-completions # # Must be sourced before `complete_alias` below, # 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 . /usr/share/doc/fzf/examples/completion.bash fi