about summary refs log tree commit diff
path: root/Completion/Unix/Command/_ssh
diff options
context:
space:
mode:
authorClint Adams <clint@users.sourceforge.net>2002-02-08 08:37:31 +0000
committerClint Adams <clint@users.sourceforge.net>2002-02-08 08:37:31 +0000
commit3a223ceeea2a320f8532807ab58b07b7baa05e1f (patch)
treece773a3e8fff775dec76459ff60c8f3d514bb112 /Completion/Unix/Command/_ssh
parent841e51076d8ee00e0b4e49dd94d1f0f86f5d9330 (diff)
downloadzsh-3a223ceeea2a320f8532807ab58b07b7baa05e1f.tar.gz
zsh-3a223ceeea2a320f8532807ab58b07b7baa05e1f.tar.xz
zsh-3a223ceeea2a320f8532807ab58b07b7baa05e1f.zip
16566, 16568, 16461: improvements for scp completion.
Diffstat (limited to 'Completion/Unix/Command/_ssh')
-rw-r--r--Completion/Unix/Command/_ssh21
1 files changed, 16 insertions, 5 deletions
diff --git a/Completion/Unix/Command/_ssh b/Completion/Unix/Command/_ssh
index 40664114c..672031c36 100644
--- a/Completion/Unix/Command/_ssh
+++ b/Completion/Unix/Command/_ssh
@@ -1,12 +1,23 @@
 #compdef ssh slogin=ssh scp ssh-add ssh-agent ssh-keygen
 
 _remote_files () {
-  # This is extremely simple-minded; could parse "ls -F" output to do
-  # colorings and LIST_TYPES and so on, but I'm just not that ambitious.
-  local expl
+  # There should be coloring based on all the different ls -F classifiers.
+  local expl remfiles remdispf remdispd
 
-  _wanted files expl 'remote files' \
-      compadd $(ssh -a -x ${words[CURRENT]%:*} echo ${words[CURRENT]#*:}\*)
+  if zstyle -T ":completion:${curcontext}:" remote-access; then
+    remfiles=(${(f)"$(ssh -a -x ${words[CURRENT]%:*} ls -d1F ${${${words[CURRENT]#*:}:h}/\\/(#e)/}/\* 2>/dev/null)"})
+
+    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)/}
+  else
+    _message 'remote files'
+  fi
 }
 
 _ssh () {