From b67e4abb100f67ca05809baab37700eb5ee0a342 Mon Sep 17 00:00:00 2001 From: Tanaka Akira Date: Fri, 10 Sep 1999 13:57:31 +0000 Subject: manual/7767 --- Completion/Builtins/_zftp | 41 +++++++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 10 deletions(-) (limited to 'Completion/Builtins/_zftp') 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='' -- cgit 1.4.1