Skip to content
Myr

[zsh] Set shell options for pathname expansion "~/.ssh/config.d/*"

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

This applies the same changes as commit 0a06fd6f for Bash (GitHub PR

authored by Koichi Murase · committed by Junegunn Choi · parent 0a06fd6 · Browse files · 1 file+13 added−2 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+13 added−2 removed

  • other:+13 added−2 removed

1 file+13 added−2 removed

modified:shell/completion.zsh+13 added-2 removed
240 unmodified lines
241# The function is expected to print hostnames, one per line as well as in the242# desired sorting and with any duplicates removed, to standard output.243if ! declare -f __fzf_list_hosts > /dev/null; then244 __fzf_list_hosts() {245 setopt localoptions nonomatch246 command cat <(command tail -n +1 ~/.ssh/config ~/.ssh/config.d/* /etc/ssh/ssh_config 2> /dev/null | command grep -i '^\s*host\(name\)\? ' | awk '{for (i = 2; i <= NF; i++) print $1 " " $i}' | command grep -v '[*?%]') \245 command cat \246 <(247 # Note: To make the pathname expansion of "~/.ssh/config.d/*" work248 # properly, we need to adjust the related shell options. We need to249 # unset "NO_GLOB" (or reset "GLOB"), which disable the pathname250 # expansion totally. We need to unset "DOT_GLOB" and set "CASE_GLOB"251 # to avoid matching unwanted files. We need to set "NULL_GLOB" to252 # avoid attempting to read the literal filename '~/.ssh/config.d/*'253 # when no matching is found.254 setopt GLOB NO_DOT_GLOB CASE_GLOB NO_NOMATCH NULL_GLOB255256 command tail -n +1 ~/.ssh/config ~/.ssh/config.d/* /etc/ssh/ssh_config 2> /dev/null | command grep -i '^\s*host\(name\)\? ' | awk '{for (i = 2; i <= NF; i++) print $1 " " $i}' | command grep -v '[*?%]'257 ) \258 <(command grep -oE '^[[a-z0-9.,:-]+' ~/.ssh/known_hosts 2> /dev/null | tr ',' '\n' | tr -d '[' | awk '{ print $1 " " $1 }') \259 <(command grep -v '^\s*\(#\|$\)' /etc/hosts 2> /dev/null | command grep -Fv '0.0.0.0' | command sed 's/#.*//') |260 awk '{for (i = 2; i <= NF; i++) print $i}' | sort -u261 }
165 unmodified lines