about summary refs log tree commit diff
path: root/Completion
diff options
context:
space:
mode:
authorSATOH Fumiyasu <fumiyas@osstech.co.jp>2020-03-08 16:10:45 +0900
committerOliver Kiddle <okiddle@yahoo.co.uk>2020-07-08 17:25:20 +0200
commita0a27473fe0e344a9deb4f042c24e31a2e22bcc5 (patch)
tree037f0e19779ed97340d4dd15d7a449c8653e976c /Completion
parentdc8061ebe4d310492fee24412743db6c8afe4362 (diff)
downloadzsh-a0a27473fe0e344a9deb4f042c24e31a2e22bcc5.tar.gz
zsh-a0a27473fe0e344a9deb4f042c24e31a2e22bcc5.tar.xz
zsh-a0a27473fe0e344a9deb4f042c24e31a2e22bcc5.zip
github #50: Complete hosts in "Match" directive
Diffstat (limited to 'Completion')
-rw-r--r--Completion/Unix/Type/_ssh_hosts12
1 files changed, 12 insertions, 0 deletions
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;;