1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-01-17 22:31:12 +01:00
zsh/Completion/Builtins/_zftp

93 lines
2.5 KiB
Text
Raw Normal View History

1999-04-15 20:25:40 +02:00
#compdef -p zf*
1999-04-15 20:17:36 +02:00
# Completion for zftp builtin and zf* functions. The functions
1999-09-10 15:57:31 +02:00
# zfcd_match and zfget_match (also used for old-style completion)
1999-04-15 20:17:36 +02:00
# need to be installed for remote file and directory completion to work.
1999-11-15 13:01:46 +01:00
# emulate -L zsh
1999-09-10 15:57:31 +02:00
# Don't try any more completion after this.
_compskip=all
2000-02-03 18:22:40 +01:00
local subcom expl curcontext="${curcontext}"
1999-04-15 20:17:36 +02:00
1999-04-15 20:18:42 +02:00
if [[ $words[1] = zftp ]]; then
1999-04-15 20:25:40 +02:00
if [[ $CURRENT -eq 2 ]]; then
2000-03-23 05:19:26 +01:00
_wanted commands expl sub-command \
compadd open params user login type ascii binary mode put \
1999-11-15 13:01:46 +01:00
putat get getat append appendat ls dir local remote mkdir rmdir \
session rmsession
1999-04-15 20:17:36 +02:00
return
fi
1999-04-15 20:18:42 +02:00
subcom=$words[2]
2000-02-03 18:22:40 +01:00
curcontext="${curcontext/:zftp:/:zftp-${words[2]}:}"
1999-04-15 20:17:36 +02:00
else
1999-04-15 20:18:42 +02:00
subcom=$words[1]
1999-04-15 20:17:36 +02:00
fi
case $subcom in
*(cd|ls|dir))
1999-09-10 15:57:31 +02:00
# complete remote directories
2000-03-23 05:19:26 +01:00
_wanted directories && zfcd_match $PREFIX $SUFFIX
1999-08-23 12:07:17 +02:00
;;
1999-04-15 20:17:36 +02:00
*(get(|at)|gcp|delete|remote))
1999-08-23 12:07:17 +02:00
# complete remote files
2000-03-23 05:19:26 +01:00
_wanted files && zfget_match $PREFIX $SUFFIX
1999-08-23 12:07:17 +02:00
;;
1999-04-15 20:17:36 +02:00
*(put(|at)|pcp))
1999-08-23 12:07:17 +02:00
# complete local files
2000-03-23 05:19:26 +01:00
_wanted files && _files
1999-08-23 12:07:17 +02:00
;;
1999-04-15 20:17:36 +02:00
*(open|anon|params))
1999-08-23 12:07:17 +02:00
# complete hosts: should do cleverer stuff with user names
2000-03-23 05:19:26 +01:00
_wanted hosts && _hosts
1999-08-23 12:07:17 +02:00
;;
1999-04-15 20:17:36 +02:00
1999-06-18 12:55:45 +02:00
*(goto|mark))
1999-08-23 12:07:17 +02:00
# complete bookmarks. First decide if ncftp mode is go.
2000-03-23 05:19:26 +01:00
_wanted bookmarks || return 1
1999-08-23 12:07:17 +02:00
if [[ $words[2] = -*n* ]]; then
if [[ -f ~/.ncftp/bookmarks ]]; then
2000-03-23 05:19:26 +01:00
_loop bookmarks expl bookmark \
compadd - $(awk -F, 'NR > 2 { print $1 }' ~/.ncftp/bookmarks)
1999-08-23 12:07:17 +02:00
fi
else
if [[ -f ${ZFTP_BMFILE:=${ZDOTDIR:-$HOME}/.zfbkmarks} ]]; then
2000-03-23 05:19:26 +01:00
_loop bookmarks expl bookmark \
compadd - $(awk '{print $1}' $ZFTP_BMFILE)
1999-08-23 12:07:17 +02:00
fi
1999-06-18 12:55:45 +02:00
fi
1999-08-23 12:07:17 +02:00
;;
1999-06-18 12:55:45 +02:00
1999-09-10 15:57:31 +02:00
*session)
# complete sessions, excluding the current one.
2000-03-23 05:19:26 +01:00
_wanted sessions expl 'another FTP session' \
compadd - ${$(zftp session):#$ZFTP_SESSION}
1999-09-10 15:57:31 +02:00
;;
*transfer)
# complete arguments like sess1:file1 sess2:file2
if [[ $PREFIX = *:* ]]; then
# complete file in the given session
2000-03-23 05:19:26 +01:00
_wanted files || return 1
1999-09-10 15:57:31 +02:00
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
2000-03-23 05:19:26 +01:00
_wanted sessions expl 'FTP session' compadd -S : - $(zftp session)
1999-09-10 15:57:31 +02:00
fi
;;
1999-04-15 20:17:36 +02:00
*)
1999-08-23 12:07:17 +02:00
# dunno... try ordinary completion after all.
1999-08-24 11:17:41 +02:00
_compskip=''
1999-08-23 12:07:17 +02:00
return 1
;;
1999-04-15 20:17:36 +02:00
esac