about summary refs log tree commit diff
path: root/Completion/Unix/Command
diff options
context:
space:
mode:
authorOliver Kiddle <opk@users.sourceforge.net>2003-01-07 08:51:10 +0000
committerOliver Kiddle <opk@users.sourceforge.net>2003-01-07 08:51:10 +0000
commit0e037e4d99a109620f4413d18a38f9d955051ccd (patch)
tree042812dbce24f310f7e61deb367a6499109b2d59 /Completion/Unix/Command
parentcd28eb9c7104aaee83fcd3857cac4e7794af10c8 (diff)
downloadzsh-0e037e4d99a109620f4413d18a38f9d955051ccd.tar.gz
zsh-0e037e4d99a109620f4413d18a38f9d955051ccd.tar.xz
zsh-0e037e4d99a109620f4413d18a38f9d955051ccd.zip
18058: complete remote files for rcp
Diffstat (limited to 'Completion/Unix/Command')
-rw-r--r--Completion/Unix/Command/_rlogin29
1 files changed, 28 insertions, 1 deletions
diff --git a/Completion/Unix/Command/_rlogin b/Completion/Unix/Command/_rlogin
index bdfe2b44c..32f49e19a 100644
--- a/Completion/Unix/Command/_rlogin
+++ b/Completion/Unix/Command/_rlogin
@@ -1,5 +1,32 @@
 #compdef rlogin rsh remsh=rsh rcp
 
+_rcp_remote_files () {
+  # There should be coloring based on all the different ls -F classifiers.
+  local expl remfiles remdispf remdispd suf ret=1
+
+  if zstyle -T ":completion:${curcontext}:" remote-access; then
+    remfiles=(${(M)${(f)"$(rsh ${words[CURRENT]%%:*} ls -d1F ${PREFIX%%[^./][^/]#}\* 2>/dev/null)"}%%[^/]#(|/)})
+    compset -P '*/'
+    compset -S '/*' || suf='remote file'
+
+    remdispf=(${remfiles:#*/})
+    remdispd=(${(M)remfiles:#*/})
+
+    _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 -e remote-files 'remote file'
+  fi
+}
+
 _rlogin () {
   case "$service" in
   rlogin)
@@ -38,7 +65,7 @@ _rlogin () {
 
     if [[ -n "$state" ]]; then
       if compset -P '*:'; then
-	_files && ret=0
+	_rcp_remote_files && ret=0
       elif compset -P '*@'; then
         _wanted hosts expl host _rlogin_hosts -S: && ret=0
       else