Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH 2/2] Use _multi_parts for scp remote file completion and complete abbrevs
- X-seq: zsh-workers 25881
 
- From: JÃrg Sommer <joerg@xxxxxxxxxxxx>
 
- To: zsh-workers@xxxxxxxxxx
 
- Subject: [PATCH 2/2] Use _multi_parts for scp remote file completion and complete abbrevs
 
- Date: Mon, 13 Oct 2008 19:19:34 +0200
 
- Cc: JÃrg Sommer <joerg@xxxxxxxxxxxx>
 
- Dkim-signature: v=1; a=rsa-sha256; c=simple/simple; d=gnuu.de; s=banki;	t=1223935448; i=@xxxxxxxxxxxx; 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=
 
- In-reply-to: <1223918374-21544-1-git-send-email-joerg@xxxxxxxxxxxx>
 
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
 
- References: <1223918374-21544-1-git-send-email-joerg@xxxxxxxxxxxx>
 
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author