From d374f2b1800d54d37a8e4c5299e824874a0489ed Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Fri, 9 Dec 2011 22:39:08 +0000 Subject: 29918: Completion: Add new _remote_files() helper and use it to reduce code duplication. --- Completion/Unix/Command/_ssh | 38 ++------------------------------------ 1 file changed, 2 insertions(+), 36 deletions(-) (limited to 'Completion/Unix/Command/_ssh') diff --git a/Completion/Unix/Command/_ssh b/Completion/Unix/Command/_ssh index bd23c3627..a6f2b40a2 100644 --- a/Completion/Unix/Command/_ssh +++ b/Completion/Unix/Command/_ssh @@ -5,40 +5,6 @@ # TODO: update ssh-keygen (not based on 5.9) # TODO: sshd, ssh-keyscan, ssh-keysign - -_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 -} - _ssh () { local curcontext="$curcontext" state line expl common tmp cmds suf ret=1 typeset -A opt_args @@ -386,7 +352,7 @@ _ssh () { ;; file) if compset -P '*:'; then - _remote_files ${(kv)~opt_args[(I)-[FP1246]]/-P/-p} && ret=0 + _remote_files -- ssh ${(kv)~opt_args[(I)-[FP1246]]/-P/-p} && ret=0 elif compset -P '*@'; then suf=( -S '' ) compset -S ':*' || suf=( -r: -S: ) @@ -400,7 +366,7 @@ _ssh () { ;; rfile) if compset -P '*:'; then - _remote_files && ret=0 + _remote_files -- ssh && ret=0 elif compset -P '*@'; then _wanted hosts expl host _ssh_hosts -r: -S: && ret=0 else -- cgit 1.4.1