From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13429 invoked by alias); 5 Nov 2016 19:07:27 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 22087 Received: (qmail 14465 invoked from network); 5 Nov 2016 19:07:27 -0000 X-Qmail-Scanner-Diagnostics: from mout.gmx.net by f.primenet.com.au (envelope-from <400thecat@gmx.ch>, uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(212.227.15.18):SA:0(0.6/5.0):. Processed in 0.531567 secs); 05 Nov 2016 19:07:27 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=FREEMAIL_FROM, FROM_STARTS_WITH_NUMS,SPF_PASS autolearn=no autolearn_force=no version=3.4.1 X-Envelope-From: 400thecat@gmx.ch X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at gmx.net designates 212.227.15.18 as permitted sender) Message-ID: <581E2AE5.4040006@gmx.ch> Date: Sat, 05 Nov 2016 19:54:29 +0100 From: Fourhundred Thecat <400thecat@gmx.ch> MIME-Version: 1.0 To: zsh-users@zsh.org Subject: Re: hostname completion for ssh / scp References: <581B8BCE.2040108@gmx.ch> <161104214237.ZM18518@torch.brasslantern.com> <581D9E98.1000008@gmx.ch> <161105102455.ZM20692@torch.brasslantern.com> In-Reply-To: <161105102455.ZM20692@torch.brasslantern.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:PmnvHhxfOXoPr1CyUTwtZalggj7GKAQtPheJkiEn+m9zK15zSkI mORvEIhYNklFqhdWbcHSokacnZfTXY0FLR2W86Etq92iZWvRcvgjakwvRWGxUzgGXnTklTi f6M9vGGXwQ8FAg6Kt7uyXPob4aG3Pb00tW7MsDVkBnDP8dMDBohROY+wS7eZctK5MU7u5xG jXPBKv+o4g8v/jvznRH7Q== X-UI-Out-Filterresults: notjunk:1;V01:K0:qGHTxYHvKug=:YRyQou5HTd7DbE2aoDW5vi 521/NNgVM96IbtQ11ZD90B7AZbuXimyyHHETkj9N7IL6qRA9mI0QxtmDTl9b1XQvnb/vagU6K a8aFfX7x9Ce/bi/IzTJhi2cfa05/DQs0DNx48PIyu/Sd4eiqVRU+wJYAJoNyrFvJy2xPUAJL6 Gfeuc/GkftJUWOvjh22U6PmIcIqyjsrb5eDoG5tqLQ1BDVsbjbLfGOPwoEim93xGKV6RZ+Gxd rmnuVzuVrb5qsDHcEWAPUljB1ttdrNngoy7ovGr/jOMhrBVvEod1z9n5pFUHF2f6hUjz7CScV V55OclcSFgfspac/3PPdrzwh2pmDLuR7Pd3zQ6NJcSHt/In3CB9vSm+j2xXh+lmCvTwEyIMmK knrpRiEHi0761NcCnMkvOPKHmt43TLExXuzWCrWKb28FeIvkQOeT3kxKd6cz2Mm3CMUXJ7nLH N+Z/VqO4sFkOp2iVy5D0REMx8PYCkM1c3XkNIX5fwt+hoJ0p7uKj2rRTJNSLCEbvE9vZG/T5B 2uaatxS+Vr+2wEuS1km0rzYlxWVTqv8IMzV9ZCIt1BJkswM9tvlD2Q1pNVi+WMGldPl7Hn38X wUWQx5TJZ1kkeiTW84B8GTvcRe9Spb8bSwHS6x3E4Pqd7PItlffRJCC8Kh+ljmsnm5vCX/2NT MHi7InHvsrhXf2U23nfn/Ic0i9iH7Sq7Fd3kb7pF0VyNLUZBmk5jaXk/IR5w/5K4SEQH2I6vs LGHWcmK66MZaX+15Tf2cqDLwOnP5pKXODTNprqneK+lpgqkcYnDj9qqEZe67Uy9pHJ8398wlA RQGXcXT > On 2016-11-05 18:24, Bart Schaefer wrote: > Well, yes. The syntax of the /etc/hosts file is first an IP and then > a hostname. Somebody will possibly correct me, but I don't recall > any valid use of /etc/hosts that has lines of host names without IPs. Not true. IP address is not mandatory in /etc/hosts. You can leave it out, and only have hostnames. This is useful for host autocompletion. You don't have to type a long hostname, such as: ssh long-or-complicated-host.my-subdomain.my-domain.com instead, you just type ssh long > } > If getent isn't returning anything useful, you can replace it: > } > > } > zstyle ':completion:*:hosts' command 'cat /etc/hosts' > } > } I would like to keep the completion from ~/.ssh/config and add > } completion from /etc/hosts. > > This shouldn't change the behavior with respect to ~/.ssh/config > because that's read in _ssh_hosts rather than in _hosts where the > style above applies. > _hosts reads ~/.ssh/known_hosts whether or not the program named by > the command style returns anything. > > However, ~/.ssh/config will be skipped if the users-hosts tag finds > any matching hosts, which is likely to happen if you are starting > from a blank word, because users-hosts calls _hosts which will look > in known_hosts. If you start with a prefix on the line that matches > a host in ~/.ssh/config and does NOT match one in ~/.ssh/known_hosts, > you should get a completion. yes that is correct. But this is a terrible feature. The completion jumps to first matching hostname, completely ignoring other matching hostnames. ssh s will complete to ssh server1.mydomain.com and completely disregard system1.mydomain.com system2.mydomain.com > > } > Note there have been several other fixes/improvements to ssh host-gathering > } > since zsh 5.0. > } > } can I simply copy Unix/_ssh from zsh 5.0. and use it on zsh 4.3.17 ? > > I don't think so (you'd need at least _hosts as well) but in any case > it wouldn't change anything because even 5.0+ is not expecting you to > have just dumped a bunch of bare host names into /etc/hosts like that. >