summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--Completion/Unix/Type/_ssh_hosts12
2 files changed, 15 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 529526f38..779dc67e5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
2020-07-08 Oliver Kiddle <okiddle@yahoo.co.uk>
+ * github #50: SATOH Fumiyasu: Completion/Unix/Type/_ssh_hosts:
+ Complete hosts in "Match" directive
+
* github #53: James Pike: Completion/Unix/Type/_remote_files:
allow specifying directory name.
diff --git a/Completion/Unix/Type/_ssh_hosts b/Completion/Unix/Type/_ssh_hosts
index e20142cfd..bd5366425 100644
--- a/Completion/Unix/Type/_ssh_hosts
+++ b/Completion/Unix/Type/_ssh_hosts
@@ -19,8 +19,20 @@ fi
if [[ -r $config ]]; then
local key line host
local -a lines=("${(@f)$(<"$config")}") 2>/dev/null
+ local -a match_args
while (($#lines)); do
IFS=$'=\t ' read -r key line <<<"${lines[1]}"
+ if [[ "$key" == ((#i)match) ]]; then
+ match_args=(${(z)line})
+ while [[ $#match_args -ge 2 ]]; do
+ if [[ "${match_args[1]}" == (#i)(canonical|final|(|original)host) ]]; then
+ key="Host"
+ line="${match_args[2]//,/ }"
+ break
+ fi
+ shift 2 match_args
+ done
+ fi
case "$key" in
((#i)include)
lines[1]=("${(@f)$(cd $HOME/.ssh; cat ${(z)~line})}") 2>/dev/null;;