From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12466 invoked by alias); 5 Nov 2016 08:56:07 -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: 22085 Received: (qmail 3322 invoked from network); 5 Nov 2016 08:56:07 -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.496666 secs); 05 Nov 2016 08:56:07 -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: <581D9E98.1000008@gmx.ch> Date: Sat, 05 Nov 2016 09:55:52 +0100 From: Fourhundred Thecat <400thecat@gmx.ch> MIME-Version: 1.0 To: Bart Schaefer , zsh-users@zsh.org Subject: Re: hostname completion for ssh / scp References: <581B8BCE.2040108@gmx.ch> <161104214237.ZM18518@torch.brasslantern.com> In-Reply-To: <161104214237.ZM18518@torch.brasslantern.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:wHLHavPlR6VWRpGDum9y6BCSHw+YUwxvb0dMTdT4Gq4d+MCqDbW YKwGZ2J7DPbX37x6XBdVm9GnW+LcYTDwlLEuU/46TAT/eidCacC4fR/z5mVNV+kUjxnf3qM 1HhWRJlCEkgqoQpJPDK+UrGLdg5J37o/pf9CV87R7HF308UF5OlZVBFy2EgZNwXFUsMgsBA 8DvcugNIfte9hhFzpB6Vw== X-UI-Out-Filterresults: notjunk:1;V01:K0:Crnrnc76+7w=:jbRbbSkvfByxJWBLKJaLsi lUm4BaQ2VdMackT1r0bTiWaqaZTof1VtRvxjfUbc+fG0XzzScbc4gD9/M96EQFiIp3pbaIy3D hlQOQ2G4VQTVWkOlOAnkhORbn4T19OJjM7cegjSG5pwypsHRn2nu7eCi2PbehE2NolHhRak22 GvXRbaId5eMYUz1umrUdO4qdIYwSOpxgqEDVk5PZuyl+AMz9TEubqAV3M1s9hzZzV/+GmJ6vU ZHx1sMjiMqz5nhPfphToyxO0HAhiPwXMgztTu4bENJYNZebzpC0zT6Y21ItuIcFnq1xTICs6O Ym3cApx7k1k48wBY8CDpZYI4w7iskQbijln9/8oiAO3vxl9Gy2LnEwIQIJr50mBV8LIuVBlfI 6mtDZAxP1HxHS0YbNquNb9EPOFiSV5XOj12SVN9hxfw2RE2vS7sbUbeapCFRn7DKBdRnUe83K fakYHGyV0zxK4pgw1xuD5XR0sQsEdlWAdGFB78KKWBU3dkqhXN+ehKY5+iJ8haKDRahLlYnWm 6ECZvAxSp3bmVPpkgR2J+6SNAbvlwxAow3nEMKdk7ESnFfXL+/W8m3APUcD2C435yCey5vo47 AixwSgVCuHJuVcAW0QSlUj14xIrNzplA0Oa7NDVF9Em5jnZOBHPsLHTvH6UUq0Zdmna657os/ RGUf/q1/Ln5JPUqaa4zDE4vsATpfZQPcepKMXUhYnFmmweAf3Do7mYc86tDDPL0n6kIjCy45G 5T/RqglUPMgfEVFpBg36hAiIbvEnhT5IKFqoy1ujoUXMe7epbY5Mhv7JDdhTiHdv6OQxXh8yb 9QuaVJo > On 2016-11-05 05:42, Bart Schaefer wrote: > On Nov 3, 8:11pm, Fourhundred Thecat wrote: > } Subject: hostname completion for ssh / scp > } > } ssh > } > } it offers me only the hostnames listed in ~/.ssh/config and completely > } ignores global ones defined in /etc/hosts > } > } Tested on zsh 4.3.17 > > What does > getent hosts > return on your system? That's where _hosts gets the list of hosts. getent hosts only returns first two lines from /etc/hosts, and ignores the rest: 127.0.0.1 localhost 127.0.1.1 laptop I believe, getent hosts only returns hosts which have ip address specified in /etc/hosts, such as: 1.2.3.4 myserver1.com > 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. I cannot just use zstyle ':completion:*:hosts' command 'cat /etc/hosts ~/.ssh/config' because the syntax in ~/.ssh/config is more tricky (multiline host definition), and I don't want options to be interpreted as hostnames. > Or explicitly list all the hosts yourself: > > zstyle ':completion:*:hosts' hosts $(awk '/^[^#]/ {print $2}' /etc/hosts) same as above > 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 ?