summaryrefslogtreecommitdiff
path: root/Completion/Base/Utility
diff options
context:
space:
mode:
authorAxel Beckert <abe@deuxchevaux.org>2012-01-22 16:22:20 +0100
committerAxel Beckert <abe@deuxchevaux.org>2012-01-22 16:22:20 +0100
commitdbd9bc55f629891c29373398120d8af7e2c44732 (patch)
tree7a4f6a02ad876cdd236dbe6a8d68e172dc50a9e4 /Completion/Base/Utility
parent1a3a8694a6eae1e140d746e4c21769cdd56971c0 (diff)
parent09532a70ead07a600a3d2258837d6e3fe943f2fd (diff)
downloadzsh-dbd9bc55f629891c29373398120d8af7e2c44732.tar.gz
zsh-dbd9bc55f629891c29373398120d8af7e2c44732.zip
Merge branch 'upstream' into debian
Diffstat (limited to 'Completion/Base/Utility')
-rw-r--r--Completion/Base/Utility/.distfiles2
-rw-r--r--Completion/Base/Utility/_arguments2
-rw-r--r--Completion/Base/Utility/_remote_files77
-rw-r--r--Completion/Base/Utility/_values1
4 files changed, 81 insertions, 1 deletions
diff --git a/Completion/Base/Utility/.distfiles b/Completion/Base/Utility/.distfiles
index 97d86bdbf..d5e359ae7 100644
--- a/Completion/Base/Utility/.distfiles
+++ b/Completion/Base/Utility/.distfiles
@@ -5,5 +5,5 @@ _arg_compile _combination _regex_arguments _values
_arguments _set_command _retrieve_cache _guard
_cache_invalid _describe _sep_parts _pick_variant
_call_function _multi_parts _store_cache _regex_words
-_complete_help_generic
+_complete_help_generic _remote_files
'
diff --git a/Completion/Base/Utility/_arguments b/Completion/Base/Utility/_arguments
index 126d9c315..d70c44259 100644
--- a/Completion/Base/Utility/_arguments
+++ b/Completion/Base/Utility/_arguments
@@ -344,6 +344,7 @@ if (( $# )) && comparguments -i "$autod" "$singopt[@]" "$@"; then
context=()
state=()
+ state_descr=()
while true; do
while _tags; do
@@ -376,6 +377,7 @@ if (( $# )) && comparguments -i "$autod" "$singopt[@]" "$@"; then
if (( ! $state[(I)$action] )); then
comparguments -W line opt_args
state+=( "$action" )
+ state_descr+=( "$descr" )
if [[ -n "$usecc" ]]; then
curcontext="${oldcontext%:*}:$subc"
else
diff --git a/Completion/Base/Utility/_remote_files b/Completion/Base/Utility/_remote_files
new file mode 100644
index 000000000..c35e3d3fa
--- /dev/null
+++ b/Completion/Base/Utility/_remote_files
@@ -0,0 +1,77 @@
+#autoload
+
+# Complete files on remote systems using SSH (and other programs). Needs
+# key-based authentication with no passwords or a running ssh-agent to work.
+#
+# Usage:
+# _remote_files [--no-files] [--no-dirs] -- <cmd> [<cmd options>]
+#
+# Options:
+# - --no-files: don't complete remote files
+# - --no-dirs: don't complete remote directories
+#
+# Commands:
+# - ssh: Additional options for non-interactive use are automatically added
+# (see below).
+# - All other commands are used unaltered.
+#
+# Examples:
+# - _remote_files -- ssh
+# Use ssh to retrieve the remote paths. The "--" is not optional!
+# - _remote_files --no-files -- ssh -2 -p 42
+# Use ssh with the option -2 and -p 42 to retrieve the remote paths and
+# complete only directories.
+# - _remote_files -- rsh
+# Use rsh to retrieve the remote paths.
+
+
+# There should be coloring based on all the different ls -F classifiers.
+local expl rempat remfiles remdispf remdispd args cmd cmd_args suf ret=1
+
+if zstyle -T ":completion:${curcontext}:files" remote-access; then
+
+ # Parse options to _remote_files. Stops at the first "--".
+ zparseopts -D -E -a args -no-files -no-dirs
+ shift
+
+ # Command to run on the remote system.
+ cmd="$1"
+ shift
+
+ # Handle arguments to ssh.
+ if [[ $cmd == ssh ]]; then
+ zparseopts -D -E -a cmd_args p: 1 2 4 6 F:
+ cmd_args="-o BatchMode=yes $cmd_args -a -x"
+ else
+ cmd_args="$@"
+ fi
+
+ if [[ -z $QIPREFIX ]]
+ then rempat="${PREFIX%%[^./][^/]#}\*"
+ else rempat="${(q)PREFIX%%[^./][^/]#}\*"
+ fi
+
+ remfiles=(${(M)${(f)"$(_call_program files $cmd $cmd_args ${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
+ [[ ${args[(I)--no-files]} -eq 0 ]] && \
+ [[ -n $suf ]] && compadd "$@" "$expl[@]" -d remdispf \
+ ${(q)remdispf%[*=@|]} && ret=0
+ [[ ${args[(I)--no-dirs]} -eq 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
diff --git a/Completion/Base/Utility/_values b/Completion/Base/Utility/_values
index c2ae26465..ab0e46a9c 100644
--- a/Completion/Base/Utility/_values
+++ b/Completion/Base/Utility/_values
@@ -87,6 +87,7 @@ if compvalues -i "$@"; then
if [[ "$action" = -\>* ]]; then
compvalues -v val_args
state="${${action[3,-1]##[ ]#}%%[ ]#}"
+ state_descr="$descr"
if [[ -n "$usecc" ]]; then
curcontext="${oldcontext%:*}:$subc"
else