mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-10-27 04:40:59 +01:00
users/17382: complete URLs for vim and make _remote_files more
consistent with _files
This commit is contained in:
parent
cd0c6153e0
commit
a8ffff2cb7
5 changed files with 50 additions and 23 deletions
|
|
@ -1,3 +1,10 @@
|
||||||
|
2012-11-07 Oliver Kiddle <opk@zsh.org>
|
||||||
|
|
||||||
|
* users/17382: Completion/Unix/Type/_remote_files,
|
||||||
|
Completion/Unix/Command/_vim, Completion/Unix/Command/_git,
|
||||||
|
Completion/Unix/Type/_urls: complete URLs for vim and make
|
||||||
|
_remote_files more consistent with _files
|
||||||
|
|
||||||
2012-10-25 Peter Stephenson <p.w.stephenson@ntlworld.com>
|
2012-10-25 Peter Stephenson <p.w.stephenson@ntlworld.com>
|
||||||
|
|
||||||
* 30735: Src/parse.c: array assignments aren't simple because
|
* 30735: Src/parse.c: array assignments aren't simple because
|
||||||
|
|
@ -292,5 +299,5 @@
|
||||||
|
|
||||||
*****************************************************
|
*****************************************************
|
||||||
* This is used by the shell to define $ZSH_PATCHLEVEL
|
* This is used by the shell to define $ZSH_PATCHLEVEL
|
||||||
* $Revision: 1.5751 $
|
* $Revision: 1.5752 $
|
||||||
*****************************************************
|
*****************************************************
|
||||||
|
|
|
||||||
|
|
@ -5451,7 +5451,7 @@ __git_remote_repositories () {
|
||||||
service= _ssh
|
service= _ssh
|
||||||
|
|
||||||
if compset -P '*:'; then
|
if compset -P '*:'; then
|
||||||
_remote_files --no-files -- ssh
|
_remote_files -/ -- ssh
|
||||||
else
|
else
|
||||||
_ssh_hosts -S:
|
_ssh_hosts -S:
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
_vim_files () {
|
_vim_files () {
|
||||||
case $PREFIX in
|
case $PREFIX in
|
||||||
(+*) _files -P './' $* && return 0 ;;
|
(+*) _files -P './' $* && return 0 ;;
|
||||||
|
(scp|http(|s)|(|s)ftp):*) _urls ;;
|
||||||
(*) _files $* ;;
|
(*) _files $* ;;
|
||||||
esac
|
esac
|
||||||
case $PREFIX in
|
case $PREFIX in
|
||||||
|
|
@ -21,14 +22,10 @@ arguments=(
|
||||||
'( -e -E -s -d -y)-v[vi mode]'
|
'( -e -E -s -d -y)-v[vi mode]'
|
||||||
'(-v -E -d -y)-e[ex mode]'
|
'(-v -E -d -y)-e[ex mode]'
|
||||||
'(-v -e -d -y)-E[improved ex mode]'
|
'(-v -e -d -y)-E[improved ex mode]'
|
||||||
'(-v -e -E -s -y)-d[diff mode]'
|
|
||||||
'(-v -e -E -s -d )-y[easy mode]'
|
'(-v -e -E -s -d )-y[easy mode]'
|
||||||
'-R[readonly mode]'
|
|
||||||
'-Z[restricted mode]'
|
|
||||||
'-m[modifications (writing files) not allowed]'
|
'-m[modifications (writing files) not allowed]'
|
||||||
'-M[modifications in text not allowed]'
|
'-M[modifications in text not allowed]'
|
||||||
'-b[binary mode]'
|
'-b[binary mode]'
|
||||||
'-g[start with GUI]'
|
|
||||||
'-l[lisp mode]'
|
'-l[lisp mode]'
|
||||||
'-C[start in compatible mode]'
|
'-C[start in compatible mode]'
|
||||||
'-N[start in incompatible mode]'
|
'-N[start in incompatible mode]'
|
||||||
|
|
@ -52,7 +49,6 @@ arguments=(
|
||||||
'(-A -H )-F[start in Farsi mode]'
|
'(-A -H )-F[start in Farsi mode]'
|
||||||
'-T[set terminal type]:::_terminals'
|
'-T[set terminal type]:::_terminals'
|
||||||
'-u[use given vimrc file instead of default .vimrc]::rc file:_files'
|
'-u[use given vimrc file instead of default .vimrc]::rc file:_files'
|
||||||
'-U[use given gvimrc file instead of default .gvimrc]::rc file:_files'
|
|
||||||
'--noplugin[do not load plugin scripts]'
|
'--noplugin[do not load plugin scripts]'
|
||||||
'-o-[number of windows to open (default: one for each file)]::window count: '
|
'-o-[number of windows to open (default: one for each file)]::window count: '
|
||||||
'-O-[number of windows to vertically split open (default is one for each file)]::window count: '
|
'-O-[number of windows to vertically split open (default is one for each file)]::window count: '
|
||||||
|
|
@ -76,7 +72,6 @@ arguments=(
|
||||||
'--remote-tab-wait[as --remote-wait but open tab page for each file]:*:file:_vim_files'
|
'--remote-tab-wait[as --remote-wait but open tab page for each file]:*:file:_vim_files'
|
||||||
'--remote-tab-wait-silent[as --remote-wait-silent but open tab page for each file]:*:file:_vim_files'
|
'--remote-tab-wait-silent[as --remote-wait-silent but open tab page for each file]:*:file:_vim_files'
|
||||||
'--remote-expr[evaluate given expression in a vim server and print result]:expression: '
|
'--remote-expr[evaluate given expression in a vim server and print result]:expression: '
|
||||||
'--echo-wid[echo window ID on STDOUT, GUI version only]'
|
|
||||||
'--literal[do not expand wildcards in arguments (this is useless with ZSH)]'
|
'--literal[do not expand wildcards in arguments (this is useless with ZSH)]'
|
||||||
'(- *)--serverlist[list available vim servers and exit]'
|
'(- *)--serverlist[list available vim servers and exit]'
|
||||||
'--servername[name of vim server to send to or name of server to become]:server name:->server'
|
'--servername[name of vim server to send to or name of server to become]:server name:->server'
|
||||||
|
|
@ -88,6 +83,20 @@ arguments=(
|
||||||
'(* -q)-t[edit file where tag is defined]:tag:_complete_tag'
|
'(* -q)-t[edit file where tag is defined]:tag:_complete_tag'
|
||||||
'(-t -q)*:file:_vim_files'
|
'(-t -q)*:file:_vim_files'
|
||||||
)
|
)
|
||||||
|
[[ $service != *g* ]] && arguments+='-g[start with GUI]'
|
||||||
|
[[ $service != r* ]] && arguments+='-Z[restricted mode]'
|
||||||
|
[[ $service != *diff ]] && arguments+='(-v -e -E -s -y)-d[diff mode]'
|
||||||
|
[[ $service != *view ]] && arguments+='-R[readonly mode]'
|
||||||
|
[[ $service = *g* ]] || (( ${words[(I)-g]} )) && arguments+=(
|
||||||
|
'-font:font:_xft_fonts'
|
||||||
|
'-geometry:geometry:_x_geometry'
|
||||||
|
'(-rv -reverse)'{-rv,-reverse}'[use reverse video]'
|
||||||
|
'-display:display:_x_display'
|
||||||
|
'--role[set unique role to identify main window]:role'
|
||||||
|
'--socketid[open vim inside another GTK widget]:xid'
|
||||||
|
'--echo-wid[echo window ID on stdout]'
|
||||||
|
'-U[use given gvimrc file instead of default .gvimrc]::rc file:_files'
|
||||||
|
)
|
||||||
|
|
||||||
_arguments -C -S $arguments && return
|
_arguments -C -S $arguments && return
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,11 +4,13 @@
|
||||||
# key-based authentication with no passwords or a running ssh-agent to work.
|
# key-based authentication with no passwords or a running ssh-agent to work.
|
||||||
#
|
#
|
||||||
# Usage:
|
# Usage:
|
||||||
# _remote_files [--no-files] [--no-dirs] -- <cmd> [<cmd options>]
|
# _remote_files [-/] [-g glob] [-h host] -- <cmd> [<cmd options>]
|
||||||
#
|
#
|
||||||
# Options:
|
# Options:
|
||||||
# - --no-files: don't complete remote files
|
# - -/: only complete directories
|
||||||
# - --no-dirs: don't complete remote directories
|
# - -g: specify a pattern to match against files
|
||||||
|
# p, = and * glob qualifiers supported
|
||||||
|
# - -h: specify the remote host, default is ${IPREFIX%:}
|
||||||
#
|
#
|
||||||
# Commands:
|
# Commands:
|
||||||
# - ssh: Additional options for non-interactive use are automatically added
|
# - ssh: Additional options for non-interactive use are automatically added
|
||||||
|
|
@ -27,12 +29,14 @@
|
||||||
|
|
||||||
# There should be coloring based on all the different ls -F classifiers.
|
# 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
|
local expl rempat remfiles remdispf remdispd args cmd cmd_args suf ret=1
|
||||||
|
local glob host
|
||||||
|
|
||||||
if zstyle -T ":completion:${curcontext}:files" remote-access; then
|
if zstyle -T ":completion:${curcontext}:files" remote-access; then
|
||||||
|
|
||||||
# Parse options to _remote_files. Stops at the first "--".
|
# Parse options to _remote_files. Stops at the first "--".
|
||||||
zparseopts -D -E -a args -no-files -no-dirs
|
zparseopts -D -E -a args / g:=glob h:=host
|
||||||
shift
|
shift
|
||||||
|
(( $#host)) && shift host || host="${IPREFIX%:}"
|
||||||
|
|
||||||
# Command to run on the remote system.
|
# Command to run on the remote system.
|
||||||
cmd="$1"
|
cmd="$1"
|
||||||
|
|
@ -51,23 +55,28 @@ if zstyle -T ":completion:${curcontext}:files" remote-access; then
|
||||||
else rempat="${(q)PREFIX%%[^./][^/]#}\*"
|
else rempat="${(q)PREFIX%%[^./][^/]#}\*"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
remfiles=(${(M)${(f)"$(_call_program files $cmd $cmd_args ${IPREFIX%:} ls -d1FL -- "$rempat" 2>/dev/null)"}%%[^/]#(|/)})
|
remfiles=(${(M)${(f)"$(_call_program files $cmd $cmd_args $host ls -d1FL -- "$rempat" 2>/dev/null)"}%%[^/]#(|/)})
|
||||||
|
|
||||||
compset -P '*/'
|
compset -P '*/'
|
||||||
compset -S '/*' || suf='remote file'
|
compset -S '/*' || (( ${args[(I)-/]} )) || suf='remote file'
|
||||||
|
|
||||||
remdispf=(${remfiles:#*/})
|
remdispf=(${remfiles:#*/})
|
||||||
remdispd=(${(M)remfiles:#*/})
|
remdispd=(${(M)remfiles:#*/})
|
||||||
|
|
||||||
|
if (( $#glob )); then
|
||||||
|
match=( '(|[*=|])' )
|
||||||
|
glob[2]="${glob[2]/(#b)\(((|^)[p=\*])\)(#e)/}"
|
||||||
|
glob[2]+="${${match[1]/p/\|}/\*/\*}"
|
||||||
|
remdispf=( ${(M)remdispf:#${~glob[2]}} )
|
||||||
|
fi
|
||||||
|
|
||||||
_tags files
|
_tags files
|
||||||
while _tags; do
|
while _tags; do
|
||||||
while _next_label files expl ${suf:-remote directory}; do
|
while _next_label files expl ${suf:-remote directory}; do
|
||||||
[[ ${args[(I)--no-files]} -eq 0 ]] && \
|
[[ -n $suf ]] &&
|
||||||
[[ -n $suf ]] && compadd "$@" "$expl[@]" -d remdispf \
|
compadd "$@" "$expl[@]" -d remdispf ${(q)remdispf%[*=|]} && ret=0
|
||||||
${(q)remdispf%[*=@|]} && ret=0
|
compadd ${suf:+-S/} -r "/ \t\n\-" "$@" "$expl[@]" -d remdispd \
|
||||||
[[ ${args[(I)--no-dirs]} -eq 0 ]] && \
|
${(q)remdispd%/} && ret=0
|
||||||
compadd ${suf:+-S/} "$@" "$expl[@]" -d remdispd \
|
|
||||||
${(q)remdispd%/} && ret=0
|
|
||||||
done
|
done
|
||||||
(( ret )) || return 0
|
(( ret )) || return 0
|
||||||
done
|
done
|
||||||
|
|
@ -75,7 +75,7 @@ fi
|
||||||
scheme="$match[1]"
|
scheme="$match[1]"
|
||||||
|
|
||||||
case "$scheme" in
|
case "$scheme" in
|
||||||
http(|s)|ftp|gopher)
|
http(|s)|(|s)ftp|scp|gopher)
|
||||||
if ! compset -P //; then
|
if ! compset -P //; then
|
||||||
_wanted -C "$scheme" prefixes expl 'end of prefix' compadd -S '' "$@" //
|
_wanted -C "$scheme" prefixes expl 'end of prefix' compadd -S '' "$@" //
|
||||||
return
|
return
|
||||||
|
|
@ -143,7 +143,7 @@ host="$match[1]"
|
||||||
|
|
||||||
# Complete part after hostname
|
# Complete part after hostname
|
||||||
|
|
||||||
_tags -C local files || return 1
|
_tags remote-files files || return 1
|
||||||
|
|
||||||
if [[ "$localhttp_servername" = "$host" ]]; then
|
if [[ "$localhttp_servername" = "$host" ]]; then
|
||||||
if compset -P \~; then
|
if compset -P \~; then
|
||||||
|
|
@ -170,10 +170,12 @@ if [[ "$localhttp_servername" = "$host" ]]; then
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
while _tags; do
|
while _tags; do
|
||||||
while _next_label files expl 'local file'; do
|
(( $#urls )) && while _next_label files expl 'local file'; do
|
||||||
_path_files "$expl[@]" "$@" -W $urls/$scheme/$host "${glob[@]}" && ret=0
|
_path_files "$expl[@]" "$@" -W $urls/$scheme/$host "${glob[@]}" && ret=0
|
||||||
_path_files -S/ -r '/' "$expl[@]" -W $urls/$scheme/$host -/ && ret=0
|
_path_files -S/ -r '/' "$expl[@]" -W $urls/$scheme/$host -/ && ret=0
|
||||||
done
|
done
|
||||||
|
[[ $scheme = (scp|sftp) ]] && _requested remote-files &&
|
||||||
|
_remote_files -h $host -- ssh && ret=0
|
||||||
(( ret )) || return 0
|
(( ret )) || return 0
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue