about summary refs log tree commit diff
path: root/Completion/Builtins/_zftp
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>1999-09-10 13:57:31 +0000
committerTanaka Akira <akr@users.sourceforge.net>1999-09-10 13:57:31 +0000
commitb67e4abb100f67ca05809baab37700eb5ee0a342 (patch)
treef19c7eb1544bd6071e01155825a7aae3cc99117d /Completion/Builtins/_zftp
parentbc3256997b737f6158e9768dcf5738a7c0fbb454 (diff)
downloadzsh-b67e4abb100f67ca05809baab37700eb5ee0a342.tar.gz
zsh-b67e4abb100f67ca05809baab37700eb5ee0a342.tar.xz
zsh-b67e4abb100f67ca05809baab37700eb5ee0a342.zip
manual/7767
Diffstat (limited to 'Completion/Builtins/_zftp')
-rw-r--r--Completion/Builtins/_zftp41
1 files changed, 31 insertions, 10 deletions
diff --git a/Completion/Builtins/_zftp b/Completion/Builtins/_zftp
index 54cadc890..7aa1d94e8 100644
--- a/Completion/Builtins/_zftp
+++ b/Completion/Builtins/_zftp
@@ -1,19 +1,22 @@
 #compdef -p zf*
 
-# Don't try any more completion after this.
-_compskip=all
-
 # Completion for zftp builtin and zf* functions.  The functions
-# zfcd_match and zfget_match (used for old-style completion)
+# zfcd_match and zfget_match (also used for old-style completion)
 # need to be installed for remote file and directory completion to work.
 
+emulate -L zsh
+
+# Don't try any more completion after this.
+_compskip=all
+
 local subcom expl
 
 if [[ $words[1] = zftp ]]; then
   if [[ $CURRENT -eq 2 ]]; then
     _description expl sub-command
     compadd "$expl[@]" open params user login type ascii binary mode put \
-      putat get getat append appendat ls dir local remote mkdir rmdir
+      putat get getat append appendat ls dir local remote mkdir rmdir \
+      session rmsession
     return
   fi
   subcom=$words[2]
@@ -23,17 +26,13 @@ fi
 
 case $subcom in
   *(cd|ls|dir))
-    # complete remote directories; we could be smarter about hiding prefixes
+    # complete remote directories
     zfcd_match $PREFIX $SUFFIX
-    _description expl 'remote directory'
-    (( $#reply )) && compadd "$expl[@]" -S/ -q - $reply
     ;;
 
   *(get(|at)|gcp|delete|remote))
     # complete remote files
     zfget_match $PREFIX $SUFFIX
-    _description expl 'remote file'
-    (( $#reply )) && compadd "$expl[@]" -F fignore - $reply
     ;;
 
   *(put(|at)|pcp))
@@ -60,6 +59,28 @@ case $subcom in
     fi
     ;;
 
+  *session)
+    # complete sessions, excluding the current one.
+    _description expl 'another FTP session'
+    compadd "$expl[@]" - ${$(zftp session):#$ZFTP_SESSION}
+    ;;
+
+  *transfer)
+    # complete arguments like sess1:file1 sess2:file2
+    if [[ $PREFIX = *:* ]]; then
+      # complete file in the given session
+      local sess=${PREFIX%%:*} oldsess=$ZFTP_SESSION
+      compset -p $(( $#sess + 1 ))
+      [[ -n $sess ]] && zftp session $sess
+      zfget_match $PREFIX $SUFFIX
+      [[ -n $sess && -n $oldsess ]] && zftp session $oldsess
+    else
+      # note here we can complete the current session
+      _description expl 'FTP session'
+      compadd "$expl[@]" -S : - $(zftp session)
+    fi
+    ;;
+
   *)
     # dunno... try ordinary completion after all.
     _compskip=''