summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--etc/completions/_sshfs39
1 files changed, 37 insertions, 2 deletions
diff --git a/etc/completions/_sshfs b/etc/completions/_sshfs
index 6a6f150..57a55a9 100644
--- a/etc/completions/_sshfs
+++ b/etc/completions/_sshfs
@@ -6,6 +6,39 @@
typeset expl lstate tmp
+_remote_files () {
+ # There should be coloring based on all the different ls -F classifiers.
+ local expl rempat remfiles remdispf remdispd args suf ret=1
+
+ if zstyle -T ":completion:${curcontext}:files" remote-access; then
+ zparseopts -D -E -a args p: 1 2 4 6 F:
+ if [[ -z $QIPREFIX ]]
+ then rempat="${PREFIX%%[^./][^/]#}\*"
+ else rempat="${(q)PREFIX%%[^./][^/]#}\*"
+ fi
+ remfiles=(${(M)${(f)"$(_call_program files ssh -o BatchMode=yes $args -a -x ${IPREFIX%:} ls -d1FL "$rempat" 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 \
+ ${(q)remdispf%[*=@|]} && ret=0
+ compadd ${suf:+-S/} "$@" "$expl[@]" -d remdispd \
+ ${(q)remdispd%/} && ret=0
+ done
+ (( ret )) || return 0
+ done
+ return ret
+ else
+ _message -e remote-files 'remote file'
+ fi
+}
+
_arguments \
'-V[version]' \
'-p:tcp port:' \
@@ -64,8 +97,10 @@ while [[ -n $state ]]; do
state=''
case $lstate in
userhost)
- if compset -P '*@'; then
- _wanted hosts expl 'remote host name' _ssh_hosts
+ if compset -P '*:'; then
+ _remote_files ${(kv)~opt_args[(I)-[FP1246]]/-P/-p} && ret=0
+ elif compset -P '*@'; then
+ _wanted hosts expl 'remote host name' _ssh_hosts -S ':'
elif compset -S '@*'; then
_wanted users expl 'login name' _ssh_users -S ''
else