From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16366 invoked from network); 14 Nov 2006 15:58:59 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.7 (2006-10-05) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,FORGED_RCVD_HELO autolearn=ham version=3.1.7 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 14 Nov 2006 15:58:59 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 22277 invoked from network); 14 Nov 2006 15:58:52 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 14 Nov 2006 15:58:52 -0000 Received: (qmail 23743 invoked by alias); 14 Nov 2006 15:58:44 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 10981 Received: (qmail 23733 invoked from network); 14 Nov 2006 15:58:43 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 14 Nov 2006 15:58:43 -0000 Received: (qmail 21196 invoked from network); 14 Nov 2006 15:58:43 -0000 Received: from mx4-7.spamtrap.magma.ca (209.217.78.182) by a.mx.sunsite.dk with SMTP; 14 Nov 2006 15:58:40 -0000 Received: from mail3.magma.ca (mail3.internal.magma.ca [10.0.10.13]) by mx4-7.spamtrap.magma.ca (8.13.1/8.13.1) with ESMTP id kAEFwcFY003674 for ; Tue, 14 Nov 2006 10:58:38 -0500 Received: from princo.homelinux.org (ottawa-hs-64-26-167-4.d-ip.magma.ca [64.26.167.4]) by mail3.magma.ca (Magma's Mail Server) with ESMTP id kAEFwaF9011364 for ; Tue, 14 Nov 2006 10:58:38 -0500 Received: from jrdavid by princo.homelinux.org with local (Exim 3.36 #1 (Debian)) id 1Gk0gG-00021l-00 for ; Tue, 14 Nov 2006 10:58:36 -0500 Date: Tue, 14 Nov 2006 10:58:36 -0500 From: Jean-Rene David To: zsh-users@sunsite.dk Subject: Re: Completing from different ssh config file Message-ID: <20061114155836.GA7601@princo> Mail-Followup-To: zsh-users@sunsite.dk References: <20061113172327.GC22561@princo> <20061113195712.GA21151@cetus30.cs.utk.edu> <20061114120027.0033b6aa.pws@csr.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <20061114120027.0033b6aa.pws@csr.com> User-Agent: Mutt/1.5.13 (2006-08-11) X-magma-MailScanner-Information: Magma Mailscanner Service X-magma-MailScanner: Clean * Peter Stephenson [2006.11.14 07:15]: > Index: Completion/Unix/Command/_ssh > =================================================================== > RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_ssh,v > retrieving revision 1.29 > diff -u -r1.29 _ssh > --- Completion/Unix/Command/_ssh 3 Oct 2006 16:24:51 -0000 1.29 > +++ Completion/Unix/Command/_ssh 14 Nov 2006 11:53:15 -0000 > @@ -323,6 +323,8 @@ > > _ssh_hosts () { > local -a config_hosts > + local config > + integer ind > > if [[ "$IPREFIX" == *@ ]]; then > _combination -s '[:@]' my-accounts users-hosts "users=${IPREFIX/@}" hosts "$@" > @@ -330,7 +332,12 @@ > _combination -s '[:@]' my-accounts users-hosts \ > ${opt_args[-l]:+"users=${opt_args[-l]:q}"} hosts "$@" > fi > - if [[ -r "$HOME/.ssh/config" ]]; then > + if (( ind = ${words[(I)-F]} )); then > + config=$words[ind+1] > + else > + config="$HOME/.ssh/config" > + fi > + if [[ -r $config ]]; then > local IFS=$'\t ' key hosts host > while read key hosts; do > if [[ "$key" == (#i)host ]]; then > @@ -341,7 +348,7 @@ > esac > done > fi > - done < "$HOME/.ssh/config" > + done < "$config" > if (( ${#config_hosts} )); then > _wanted hosts expl 'remote host name' \ > compadd -M 'm:{a-zA-Z}={A-Za-z} r:|.=* r:|=*' "$@" $config_hosts Very nice. However for it to work perfectly, I had to change the assignment to: config=${~words[ind+1]} In order for "~" to get expanded. Perhaps it's safer instead of relying on globsubst to be set? Thansk a lot! -- JR