about summary refs log tree commit diff
path: root/Completion/Unix/Command/_ssh
diff options
context:
space:
mode:
authorOliver Kiddle <opk@users.sourceforge.net>2002-03-25 15:42:45 +0000
committerOliver Kiddle <opk@users.sourceforge.net>2002-03-25 15:42:45 +0000
commit5e25fa4594c238a7296f6e7ce93fac0c699e07a6 (patch)
treeea41d9dddafca2208ee312cca836e7024ce2fdf4 /Completion/Unix/Command/_ssh
parent28c052a7b71cc521ba4e9f5b48c185dd9d0bb226 (diff)
downloadzsh-5e25fa4594c238a7296f6e7ce93fac0c699e07a6.tar.gz
zsh-5e25fa4594c238a7296f6e7ce93fac0c699e07a6.tar.xz
zsh-5e25fa4594c238a7296f6e7ce93fac0c699e07a6.zip
16864: fix remote file completion with relative paths
Diffstat (limited to 'Completion/Unix/Command/_ssh')
-rw-r--r--Completion/Unix/Command/_ssh23
1 files changed, 15 insertions, 8 deletions
diff --git a/Completion/Unix/Command/_ssh b/Completion/Unix/Command/_ssh
index 672031c36..9d514de8a 100644
--- a/Completion/Unix/Command/_ssh
+++ b/Completion/Unix/Command/_ssh
@@ -2,21 +2,28 @@
 
 _remote_files () {
   # There should be coloring based on all the different ls -F classifiers.
-  local expl remfiles remdispf remdispd
+  local expl remfiles remdispf remdispd suf ret=1
 
   if zstyle -T ":completion:${curcontext}:" remote-access; then
-    remfiles=(${(f)"$(ssh -a -x ${words[CURRENT]%:*} ls -d1F ${${${words[CURRENT]#*:}:h}/\\/(#e)/}/\* 2>/dev/null)"})
+    remfiles=(${(M)${(f)"$(ssh -a -x ${words[CURRENT]%%:*} ls -d1F ${PREFIX%%[^./][^/]#}\* 2>/dev/null)"}%%[^/]#(|/)})
+    compset -P '*/'
+    compset -S '/*' || suf='remote file'
 
     remdispf=(${remfiles:#*/})
     remdispd=(${(M)remfiles:#*/})
 
-    _wanted files expl 'remote files and directories' \
-      compadd -d remdispf ${${remfiles:#*/}/[*=@|](#e)/}
-      
-    _wanted files expl 'remote files and directories' \
-      compadd -S/ -d remdispd ${${(M)remfiles:#*/}/\\/(#e)/}
+    _tags files
+    while _tags; do
+      while _next_label files expl ${suf:-remote directory}; do
+        [[ -n $suf ]] && compadd "$@" "$expl[@]" -d remdispf \
+	    ${remdispf%[*=@|]} && ret=0 
+	compadd ${suf:+-S/} "$@" "$expl[@]" -d remdispd \
+	    ${remdispd%/} && ret=0
+      done
+      (( ret )) || return 0
+    done
   else
-    _message 'remote files'
+    _message 'remote file'
   fi
 }