aboutsummaryrefslogtreecommitdiff
path: root/bash/bash_completion.d/_ssh_config_hosts.bash
diff options
context:
space:
mode:
Diffstat (limited to 'bash/bash_completion.d/_ssh_config_hosts.bash')
-rw-r--r--bash/bash_completion.d/_ssh_config_hosts.bash29
1 files changed, 17 insertions, 12 deletions
diff --git a/bash/bash_completion.d/_ssh_config_hosts.bash b/bash/bash_completion.d/_ssh_config_hosts.bash
index 0959f52b..16265e8a 100644
--- a/bash/bash_completion.d/_ssh_config_hosts.bash
+++ b/bash/bash_completion.d/_ssh_config_hosts.bash
@@ -3,23 +3,28 @@ _ssh_config_hosts() {
# Iterate through SSH client config paths
local config
- for config in "$HOME"/.ssh/config /etc/ssh/ssh_config ; do
+ for config in /etc/ssh/ssh_config.d/*.conf /etc/ssh/ssh_config \
+ "$HOME"/.ssh/config.d/*.conf "$HOME"/.ssh/config ; do
[[ -e $config ]] || continue
- # Read 'Host' options and their first value from file
- local option value ci
- while read -r option value _ ; do
+ # Read 'Host' options and their patterns from file
+ local option value patterns pattern ci
+ while read -r option value ; do
[[ $option == Host ]] || continue
+ read -a patterns -r \
+ < <(printf '%s\n' "$value")
# Check host value
- case $value in
- # No empties
- '') ;;
- # No wildcards
- *'*'*) ;;
- # Found a match; print it
- "$2"*) COMPREPLY[ci++]=$value ;;
- esac
+ for pattern in "${patterns[@]}" ; do
+ case $pattern in
+ # No empties
+ '') ;;
+ # No wildcards
+ *'*'*) ;;
+ # Found a match; print it
+ "$2"*) COMPREPLY[ci++]=$pattern ;;
+ esac
+ done
done < "$config"
done