zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Subject: Re: ZSH SSH completion with new Include directive in OpenSSH
Date: Thu, 25 May 2017 21:53:20 -0700	[thread overview]
Message-ID: <170525215320.ZM20457@torch.brasslantern.com> (raw)
In-Reply-To: <CAHj_Qssf8foGLrBk=zSpB8yJ=YGuaAwCJ3tntvVsmOgoLpA26A@mail.gmail.com>

On May 25,  9:51am, Nikola Milojevic wrote:
}
} I've stumbled upon that ssh completion doesn't work with the new Include
} directive in OpenSSH 7.3. That commands include ssh config files from the
} custom folder you set.
} 
} Do you have it in a roadmap to fix that?

I've forgotten again now why we have this:

  # If users-hosts matches, we shouldn't complete anything else.

My ~/.ssh/config is never read, period, because users-hosts always
returns something.

Nevertheless I suppose you're looking for something like the following
(the "Match" directive is unlikely ever to be interpreted):

diff --git a/Completion/Unix/Command/_ssh b/Completion/Unix/Command/_ssh
index 6763e24..cd106ad 100644
--- a/Completion/Unix/Command/_ssh
+++ b/Completion/Unix/Command/_ssh
@@ -680,17 +680,23 @@ _ssh_hosts () {
     config="$HOME/.ssh/config"
   fi
   if [[ -r $config ]]; then
-    local key hosts host
-    while IFS=$'=\t ' read -r key hosts; do
-      if [[ "$key" == (#i)host ]]; then
-         for host in ${(z)hosts}; do
-            case $host in
-            (*[*?]*) ;;
-            (*) config_hosts+=("$host") ;;
-            esac
-         done
-      fi
-    done < "$config"
+    local key line host
+    local -a lines=("${(@f)$(<"$config")}")
+    while (($#lines)); do
+      IFS=$'=\t ' read -r key line <<<"${lines[1]}"
+      case "$key" in
+      ((#i)include)
+        lines[1]=("${(@f)$(cd $HOME/.ssh; cat ${(z)~line})}");;
+      ((#i)host(|name))
+        for host in ${(z)line}; do
+          case $host in
+          (*[*?]*) ;;
+          (*) config_hosts+=("$host") ;;
+          esac
+        done; ;&
+      (*) shift lines;;
+      esac
+    done
     if (( ${#config_hosts} )); then
       _wanted hosts expl 'remote host name' \
         compadd -M 'm:{a-zA-Z}={A-Za-z} r:|.=* r:|=*' "$@" $config_hosts


  reply	other threads:[~2017-05-26  4:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-25  9:51 Nikola Milojević
2017-05-26  4:53 ` Bart Schaefer [this message]
2017-05-26 10:53   ` Daniel Shahaf
2017-05-26 11:02     ` Peter Stephenson
2017-05-27  0:03       ` Bart Schaefer
2017-05-27  1:34         ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=170525215320.ZM20457@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).