From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2354 invoked from network); 13 Oct 2008 22:04:51 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=AWL autolearn=ham version=3.2.5 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 13 Oct 2008 22:04:51 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 1328 invoked from network); 13 Oct 2008 22:04:26 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 13 Oct 2008 22:04:26 -0000 Received: (qmail 8654 invoked by alias); 13 Oct 2008 22:04:15 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 25881 Received: (qmail 8622 invoked from network); 13 Oct 2008 22:04:12 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 13 Oct 2008 22:04:12 -0000 Received: from uucp.gnuu.de (unknown [83.246.114.63]) by bifrost.dotsrc.org (Postfix) with ESMTP id E30F380524C0 for ; Tue, 14 Oct 2008 00:04:08 +0200 (CEST) Received: by uucp.gnuu.de (Postfix, from userid 10) id 3471C488080; Tue, 14 Oct 2008 00:04:07 +0200 (CEST) X-DKIM: Sendmail DKIM Filter v2.5.2 uucp.gnuu.de 3471C488080 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=gnuu.de; s=banki; t=1223935448; i=@alea.gnuu.de; bh=ulGXjN47qwMpA+4iR2+56WbJ6U+NhwdSx bZI770Yd/s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To: References:MIME-Version:Content-Type:Content-Transfer-Encoding; b=JOdIc0M4Q8ItnFhcZQE502UfpR9bvuCLhg239hYZ/aOxPMz8mf5zUXWpJNwY+Nqse ix75V9FDMF5/7Xw7HkvpknQPOvo3j3QkMCetbfa+V4f4udrD8w2kyLRGkelri0N50ZN oL9IGqadHDkBNvynmyw/mQI5hX9v8nJpPW/gU4s= Received: from ibook.localnet ([192.168.0.5] helo=alea.gnuu.de) by alea.gnuu.de with esmtp (Exim 4.63) (envelope-from ) id 1KpVTU-0001yy-MV for zsh-workers@sunsite.dk; Tue, 14 Oct 2008 00:01:12 +0200 Received: from joerg by alea.gnuu.de with local (Exim 4.69) (envelope-from ) id 1KpR4w-0005by-Ts; Mon, 13 Oct 2008 19:19:35 +0200 From: =?utf-8?q?J=C3=B6rg=20Sommer?= To: zsh-workers@sunsite.dk Cc: =?utf-8?q?J=C3=B6rg=20Sommer?= Subject: [PATCH 2/2] Use _multi_parts for scp remote file completion and complete abbrevs Date: Mon, 13 Oct 2008 19:19:34 +0200 Message-Id: <1223918374-21544-2-git-send-email-joerg@alea.gnuu.de> X-Mailer: git-send-email 1.6.0.2 In-Reply-To: <1223918374-21544-1-git-send-email-joerg@alea.gnuu.de> References: <1223918374-21544-1-git-send-email-joerg@alea.gnuu.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Virus-Scanned: ClamAV 0.92.1/8417/Mon Oct 13 09:34:29 2008 on bifrost X-Virus-Status: Clean This patches uses the function _multi_parts to simplify the code. This has the drawbacks that: • The completion description doesn't contain the file type anymore, i.e. you don't get the suffixes @, |, * and =. • The directory separator / isn't automaticly removed from the end, if you insert a space. With _multi_parts it's easier to do completion of abbreviated path like /u/s/d/zsh. So do it. --- Completion/Unix/Command/_ssh | 27 +++++---------------------- 1 files changed, 5 insertions(+), 22 deletions(-) diff --git a/Completion/Unix/Command/_ssh b/Completion/Unix/Command/_ssh index 293732c..1ad22f8 100644 --- a/Completion/Unix/Command/_ssh +++ b/Completion/Unix/Command/_ssh @@ -2,32 +2,15 @@ _remote_files () { # There should be coloring based on all the different ls -F classifiers. - local expl rempat remfiles remdispf remdispd args suf ret=1 + local expl rempat remfiles args if zstyle -T ":completion:${curcontext}:files" remote-access; then zparseopts -D -E -a args p: 1 2 4 6 F: - if [[ -z $QIPREFIX ]] - then rempat="${PREFIX%%[^./][^/]#}\*" - else rempat="${(q)PREFIX%%[^./][^/]#}\*" - fi - remfiles=(${(M)${(f)"$(_call_program files ssh -o BatchMode=yes $args -a -x ${IPREFIX%:} ls -d1FL "$rempat" 2>/dev/null)"}%%[^/]#(|/)}) - compset -P '*/' - compset -S '/*' || suf='remote file' - - remdispf=(${remfiles:#*/}) - remdispd=(${(M)remfiles:#*/}) + rempat="${(q)PREFIX//\//*/}\*" + [[ $PREFIX = (.|..|)/* ]] && rempat=${PREFIX%%/*}/${rempat#*/} + remfiles=(${(f)"$(_call_program files ssh -o BatchMode=yes $args -a -x ${IPREFIX%:} ls -d1FL "$rempat" 2>/dev/null)"%[*=@|]}) - _tags files - while _tags; do - while _next_label files expl ${suf:-remote directory}; do - [[ -n $suf ]] && compadd "$@" "$expl[@]" -d remdispf \ - ${(q)remdispf%[*=@|]} && ret=0 - compadd ${suf:+-S/} "$@" "$expl[@]" -d remdispd \ - ${(q)remdispd%/} && ret=0 - done - (( ret )) || return 0 - done - return ret + _wanted files expl 'remote file' _multi_parts $@ -- / remfiles else _message -e remote-files 'remote file' fi -- 1.6.0.2