summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@derf.homelinux.org>2009-03-21 13:43:09 +0100
committerDaniel Friesel <derf@derf.homelinux.org>2009-03-21 13:43:09 +0100
commita9f9014e1c9fa25830f7e59d160e5d5b2366a9fd (patch)
tree050b5f4f4683ef5f64f3148031da7c5114c32fb3
parent9f789d4a57a141ab5e7776699fa01752a84b7557 (diff)
_sshfs: Added completion for remote directories (again, from _ssh)
-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