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



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