From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14207 invoked from network); 21 Jan 2005 12:15:25 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 21 Jan 2005 12:15:25 -0000 Received: (qmail 32803 invoked from network); 21 Jan 2005 12:15:19 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 21 Jan 2005 12:15:19 -0000 Received: (qmail 24322 invoked by alias); 21 Jan 2005 12:15:04 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 8407 Received: (qmail 24312 invoked from network); 21 Jan 2005 12:15:03 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 21 Jan 2005 12:15:03 -0000 Received: (qmail 31669 invoked from network); 21 Jan 2005 12:15:03 -0000 Received: from mailsc1.simcon-mt.com (195.27.129.236) by a.mx.sunsite.dk with SMTP; 21 Jan 2005 12:15:02 -0000 Received: from localhost (localhost [127.0.0.1]) by mailsc1.simcon-mt.com (Postfix) with ESMTP id A665B3247F; Fri, 21 Jan 2005 13:15:01 +0100 (CET) Received: from localhost (localhost.local [127.0.0.1]) by gate.local (Postfix) with ESMTP id 0DC4A103D6; Fri, 21 Jan 2005 13:15:00 +0100 (CET) Received: by vandal.local (Postfix, from userid 1001) id 462F2AF172; Fri, 21 Jan 2005 13:13:05 +0100 (CET) Date: Fri, 21 Jan 2005 13:13:05 +0100 From: "Andrei A. Voropaev" To: Peter Stephenson Cc: zsh-users@sunsite.dk Subject: Re: completing file names Message-ID: <20050121121305.GE19548@vandal.simcon-mt.de> Mail-Followup-To: Peter Stephenson , zsh-users@sunsite.dk References: <20050121092926.GD19548@vandal.simcon-mt.de> <200501211046.j0LAkWuO007499@news01.csr.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200501211046.j0LAkWuO007499@news01.csr.com> User-Agent: Mutt/1.5.6i X-Virus-Scanned: by amavisd-new at local gate X-Spam-Checker-Version: SpamAssassin 3.0.2 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, score=-2.6 required=6.0 tests=AWL,BAYES_00 autolearn=ham version=3.0.2 X-Spam-Hits: -2.6 On Fri, Jan 21, 2005 at 10:46:32AM +0000, Peter Stephenson wrote: > "Andrei A. Voropaev" wrote: > > Completion is very good, but very complex to quickly understand it :) So > > far I've configured everything as compinstall was guiding and I'm > > satisfied. Only one thing bothers me. I would like to get the list of > > hosts not from /etc/hosts file but from some other file. Because then I > > can rely on DNS to find the appropriate IP for given file name. And > > names I can collect say in ~/.known_hosts one host per line. How can I > > set it up? > > You need to set the "hosts" style to the list of values in the file. > > zstyle ':completion:*' hosts $(<~/.known_hosts) > > should be good enough (host names don't need special quoting). > > > (in fact ~/.ssh/known_hosts can be such file, but there the host name is > > followed by lots of things on the line :) > > You can do that, too: > > zstyle ':completion:*' hosts ${${(f)"$(<~/.ssh/known_hosts)"}%%[[:space:],]*} > > This is using zsh's CompletelyImpenetrableExpansionSystem (TM): > > "$(<~/.ssh/known_hosts)" > > produces the contents of the file as a single string. > > ${(f)...} > > splits that into an array of strings, one for each line of the file. > > ${...%%[[:space:],]*} > > for each element of the array, strips off everything from the first > space or comma on, leaving the initial hostname in each case. (My > ~/.ssh/known_hosts has IP addresses after a comma, which we don't want.) Perfect. It works :) On the note of completion. I've noticed that now when I say 'scp host:/path/files/* .' zsh complains that there were no matches found. To work around this I had to put quotes around the host:/path/files/*. I've tried to use zstyle ':completion:*' preserve-prefix '(//[^/]##/|[^:/]##:)' bur for some reason it didn't help. So I guess this style is not the right one :) What would be the right action (beside putting it in quotes?) -- Minds, like parachutes, function best when open