summaryrefslogtreecommitdiff
path: root/Completion/Builtins
diff options
context:
space:
mode:
Diffstat (limited to 'Completion/Builtins')
-rw-r--r--Completion/Builtins/_autoload11
-rw-r--r--Completion/Builtins/_cd48
-rw-r--r--Completion/Builtins/_compdef54
-rw-r--r--Completion/Builtins/_disable12
-rw-r--r--Completion/Builtins/_emulate6
-rw-r--r--Completion/Builtins/_enable12
-rw-r--r--Completion/Builtins/_fc30
-rw-r--r--Completion/Builtins/_nothing2
-rw-r--r--Completion/Builtins/_pids26
-rw-r--r--Completion/Builtins/_popd55
-rw-r--r--Completion/Builtins/_sched24
-rw-r--r--Completion/Builtins/_signals12
-rw-r--r--Completion/Builtins/_stat20
-rw-r--r--Completion/Builtins/_zcompile22
-rw-r--r--Completion/Builtins/_zftp100
-rw-r--r--Completion/Builtins/_zpty10
-rw-r--r--Completion/Builtins/_zstyle145
17 files changed, 437 insertions, 152 deletions
diff --git a/Completion/Builtins/_autoload b/Completion/Builtins/_autoload
index 4f506baeb..238b79e95 100644
--- a/Completion/Builtins/_autoload
+++ b/Completion/Builtins/_autoload
@@ -1,3 +1,10 @@
-#defcomp autoload
+#compdef autoload
-complist -s '${^fpath}/*(N:t)'
+local expl
+
+if (( $words[(I)[-+]*w*] )); then
+ _description files expl 'zwc file'
+ _files "$expl[@]" -g '*.zwc'
+else
+ _wanted functions expl 'shell function' compadd - ${^fpath}/*(N:t)
+fi
diff --git a/Completion/Builtins/_cd b/Completion/Builtins/_cd
index f3ce67ec7..803bcbda5 100644
--- a/Completion/Builtins/_cd
+++ b/Completion/Builtins/_cd
@@ -1,3 +1,47 @@
-#defcomp cd
+#compdef cd chdir pushd
-_files -W cdpath -g '*(-/)'
+# Handling of cd.
+# - Normally just completes directories. Uses cdpath if that's set
+# and the string doesn't begin with ~, /, ./ or ../.
+# - In the second argument to cd for the form `cd old new', completes
+# possible `new' strings by examining `old' and $PWD.
+# - After - or +, completes numbers, but the listing
+# gives you the list of directories to complete. This turns on
+# menu-completion and lists the possibilities automatically, otherwise
+# it's not a lot of use. If you don't type the + or - it will
+# complete directories as normal.
+
+setopt localoptions nonomatch
+
+local expl
+
+if [[ CURRENT -eq 3 ]]; then
+ # cd old new: look for old in $PWD and see what can replace it
+ local rep
+ # Get possible completions using word in position 2
+ rep=(${~PWD/$words[2]/*}~$PWD(-/N))
+ # Now remove all the common parts of $PWD and the completions from this
+ rep=(${${rep#${PWD%%$words[2]*}}%${PWD#*$words[2]}})
+ (( $#rep )) && _wanted -C replacement strings expl replacement compadd $rep
+elif _popd || [[ $PREFIX != (\~|/|./|../)* && $#cdpath -ne 0 ]]; then
+ local tdir tdir2
+
+ # With cdablevars, we can convert foo/bar/... to ~foo/bar/... if
+ # there is no directory foo. In that case we could also complete
+ # variable names, but it hardly seems worth it.
+ # Note we need a tilde because cdablevars also allows user home
+ # directories, hence we also need nonomatch to suppress error messages.
+ if [[ -o cdablevars && -n "$PREFIX" && ! -d ${tdir::=${PREFIX%%/*}} &&
+ -d ${~tdir2::="~$tdir"} ]]; then
+ PREFIX="~$PREFIX"
+ _wanted directories expl directory _path_files -/
+ else
+ local tmpcdpath
+ tmpcdpath=(${${(@)cdpath:#.}:#$PWD})
+ _alternative \
+ 'local-directories:local directories:_path_files -/' \
+ "path-directories:directories in cdpath:_path_files -W tmpcdpath -/"
+ fi
+else
+ _wanted directories expl directory _path_files -/
+fi
diff --git a/Completion/Builtins/_compdef b/Completion/Builtins/_compdef
index 1df5758b3..d47a560c9 100644
--- a/Completion/Builtins/_compdef
+++ b/Completion/Builtins/_compdef
@@ -1,22 +1,40 @@
#compdef compdef
-local func base=2
+local state line expl list disp
-while [[ $words[base] = -* ]]; do
- case $words[base] in
- -d) delete=yes ;;
- -p) type=pattern ;;
- -k) type=key ;;
- esac
- (( base++ ))
-done
+_arguments -C -s \
+ '(-d)-a[make function autoloadable]' \
+ '(-d -p -P)-n[leave existing definitions intact]' \
+ '(-a -n -p -P -k -K)-d[delete]:*:completed command:->ccom' \
+ '(-n -d -P -k -K)-p[completion for command matching pattern]:completion function:->cfun:pattern' \
+ '(-n -d -p -k -K)-P[as -p for commands without own completion]:completion function:->cfun:pattern' \
+ '(-d -p -P -K)-k[define widget and key binding]:completion function:->cfun:widget name::style:->style:*:key' \
+ '(-d -p -P -k)-K[define multiple widgets based on function]:completion function:->cfun:widget name::style:->style:*:key' \
+ '1:completion function:->cfun' \
+ '2:commands:_command_names'
+
-if [ "$delete" ]; then
- compadd ${(k)_comps}
-else
- if [[ CURRENT -eq base ]]; then
- for func in ${^~fpath:/.}/_(|*[^~])(N:t); compadd -P_ - ${func#_}
- else
- compgen -c
- fi
-fi
+case $state in
+ ccom)
+ _wanted commands expl 'completed command' compadd - ${(k)_comps}
+ ;;
+ cfun)
+ if _wanted functions; then
+ list=( ${^fpath:/.}/_(|*[^~])(N:t) )
+ if zstyle -T ":completion:${curcontext}:functions" prefix-hidden; then
+ disp=( ${list[@]#_} )
+ _all_labels functions expl 'completion function' \
+ compadd -d disp - "$list[@]"
+ else
+ _all_labels functions expl 'completion function' compadd - "$list[@]"
+ fi
+ fi
+ ;;
+ style)
+ _wanted widgetstyle expl 'widget style' \
+ compadd -M 'r:|-=* r:|=*' \
+ complete-word delete-char-or-list expand-or-complete \
+ expand-or-complete-prefix list-choices menu-complete \
+ menu-expand-or-complete reverse-menu-complete
+ ;;
+esac
diff --git a/Completion/Builtins/_disable b/Completion/Builtins/_disable
index 063b65a7d..b3c2632ed 100644
--- a/Completion/Builtins/_disable
+++ b/Completion/Builtins/_disable
@@ -1,6 +1,8 @@
-#defcomp disable
+#compdef disable
-[[ -mcurrent -1 -*a* ]] && complist -ea
-[[ -mcurrent -1 -*f* ]] && complist -eF
-[[ -mcurrent -1 -*r* ]] && complist -ew
-[[ ! -mcurrent -1 -* ]] && complist -eB
+_arguments -C -s \
+ "(-f -r)-a[act on aliases]:*:aliases:(${(k)aliases} ${(k)galiases})" \
+ "(-a -r)-f[act on functions]:*:functions:(${(k)functions})" \
+ "(-a -f)-r[act on reserved words]:*:reserved-words:(${(k)reswords})" \
+ '-m[treat arguments as patterns]' \
+ "*:builtin command:(${(k)builtins})"
diff --git a/Completion/Builtins/_emulate b/Completion/Builtins/_emulate
new file mode 100644
index 000000000..82096a77e
--- /dev/null
+++ b/Completion/Builtins/_emulate
@@ -0,0 +1,6 @@
+#compdef emulate
+
+_arguments -C -s \
+ '-L[set local_options and local_traps as well]' \
+ '-R[reset all options instead of only those needed for script portability]' \
+ '1::shell to emulate:(zsh sh ksh csh)'
diff --git a/Completion/Builtins/_enable b/Completion/Builtins/_enable
index 22ff53ee7..991286276 100644
--- a/Completion/Builtins/_enable
+++ b/Completion/Builtins/_enable
@@ -1,6 +1,8 @@
-#defcomp enable
+#compdef enable
-[[ -mcurrent -1 -*a* ]] && complist -da
-[[ -mcurrent -1 -*f* ]] && complist -dF
-[[ -mcurrent -1 -*r* ]] && complist -dw
-[[ ! -mcurrent -1 -* ]] && complist -dB
+_arguments -C -s \
+ "(-f -r)-a[act on aliases]:*:aliases:(${(k)dis_aliases})" \
+ "(-a -r)-f[act on functions]:*:functions:(${(k)dis_functions})" \
+ "(-a -f)-r[act on reserved words]:*:reserved-words:(${(k)dis_reswords})" \
+ '-m[treat arguments as patterns]' \
+ "*:builtin command:(${(@k)dis_builtins})"
diff --git a/Completion/Builtins/_fc b/Completion/Builtins/_fc
index f0d2c03fd..e97492604 100644
--- a/Completion/Builtins/_fc
+++ b/Completion/Builtins/_fc
@@ -1,7 +1,27 @@
-#defcomp fc
+#compdef fc history
-if [[ -mcurrent -1 -*e ]]; then
- complist -c
-elif [[ -mcurrent -1 -[ARWI]## ]]; then
- _files
+local fc_common
+
+fc_common=( \
+ '(-A -R -W -I)-m[treat first argument as a pattern]' \
+ '(-A -R -W -I)-r[reverse order of the commands]' \
+ '(-A -R -W -I -e)-n[suppress line numbers]' \
+ '(-A -R -W -I -e -f -E -i)-d[print time-stamps]' \
+ '(-A -R -W -I -e -d -E -i)-f[mm/dd/yyyy format time-stamps]' \
+ '(-A -R -W -I -e -d -f -i)-E[dd.mm.yyyy format time-stamps]' \
+ '(-A -R -W -I -e -d -f -E)-i[yyyy-mm-dd format time-stamps]' \
+ '(-A -R -W -I -e)-D[print elapsed times]' \
+ '(-A -R -W -I)*::commands:_command_names -e' )
+
+if [[ $words[1] = *history ]]; then
+ _arguments -C -s "$fc_common[@]"
+else
+ _arguments -C -s \
+ '(-A -R -W -I -e)-l[list resulting commands on stdout]' \
+ '(-A -R -W -I -l -n -d -f -E -i -D)-e[specify editor to invoke]:editor to invoke:_command_names -e' \
+ '(-l -m -e -r -n -d -f -E -i -D -A -W *)-R[read history from file]:history file:_files' \
+ '(-l -m -e -r -n -d -f -E -i -D -R -W *)-A[append history to file]:history file:_files' \
+ '(-l -m -e -r -n -d -f -E -i -D -R -A *)-W[write history to file]:history file:_files' \
+ '(-l -m -e -r -n -d -f -E -i -D -A -W *)-I[read/write new events only]:history file:_files' \
+ "$fc_common[@]"
fi
diff --git a/Completion/Builtins/_nothing b/Completion/Builtins/_nothing
index 35a2558cc..38f6bee77 100644
--- a/Completion/Builtins/_nothing
+++ b/Completion/Builtins/_nothing
@@ -1,3 +1,3 @@
-#compdef true false
+#compdef true false log times whoami
_message 'no argument or option'
diff --git a/Completion/Builtins/_pids b/Completion/Builtins/_pids
index 0ffda900b..7dec90e7d 100644
--- a/Completion/Builtins/_pids
+++ b/Completion/Builtins/_pids
@@ -3,16 +3,32 @@
# If given the `-m <pattern>' option, this tries to complete only pids
# of processes whose command line match the `<pattern>'.
-local list expl match
+local out list expl match desc listargs args
+
+_wanted processes || return 1
if [[ "$1" = -m ]]; then
match="${2}*"
shift 2
fi
-_description expl 'process ID'
+zstyle -s ":completion:${curcontext}:pids" command args
+
+out="$(_call pids ps 2>/dev/null)"
-list=("${(@Mr:COLUMNS-1:)${(f@)$(ps ${=compconfig[ps_listargs]:-$=compconfig[ps_args]} 2>/dev/null)}[2,-1]:#[ ]#${PREFIX}[0-9]#${SUFFIX}[ ]*${~match}}")
+if zstyle -T ":completion:${curcontext}:processes" verbose; then
+ zstyle -s ":completion:${curcontext}:pids-list" command listargs
+ (( $#listargs )) || listargs=( "$args[@]" )
+ if [[ "$listargs" = "$args" ]]; then
+ list=("${(@Mr:COLUMNS-1:)${(f@)out}[2,-1]:#[ ]#${PREFIX}[0-9]#${SUFFIX}[ ]*${~match}}")
+ else
+ list=("${(@Mr:COLUMNS-1:)${(f@)$(_call pids-list ps 2>/dev/null)}[2,-1]:#[ ]#${PREFIX}[0-9]#${SUFFIX}[ ]*${~match}}")
+ fi
+ desc=(-ld list)
+else
+ desc=()
+fi
-compadd "$expl[@]" "$@" -ld list - \
- ${${${(M)${(f)"$(ps $=compconfig[ps_args] 2>/dev/null)"}[2,-1]:#*${~match}}## #}%% *}
+_all_labels processes expl 'process ID' \
+ compadd "$@" "$desc[@]" - \
+ ${${${(M)${(f)"${out}"}[2,-1]:#[ ]#${PREFIX}[0-9]#${SUFFIX}[ ]#*${~match}}## #}%% *}
diff --git a/Completion/Builtins/_popd b/Completion/Builtins/_popd
index 9054befb7..2a3413253 100644
--- a/Completion/Builtins/_popd
+++ b/Completion/Builtins/_popd
@@ -5,36 +5,39 @@
# way round if pushdminus is set). Note that this function is also called
# from _cd for cd and pushd.
-emulate -L zsh
setopt extendedglob nonomatch
-[[ $PREFIX = [-+]* ]] || return 1
+local expl list lines revlines disp
-local expl list lines revlines ret=1 i
+! zstyle -T ":completion:${curcontext}:directory-stack" prefix-needed ||
+ [[ $PREFIX = [-+]* ]] || return 1
-IPREFIX=$PREFIX[1]
-PREFIX=$PREFIX[2,-1]
+_wanted directory-stack || return 1
-# get the list of directories with their canonical number
-# and turn the lines into an array, removing the current directory
-lines=( ${${(f)"$(dirs -v)"}##0*} )
-if [[ ( $IPREFIX = - && ! -o pushdminus ) ||
- ( $IPREFIX = + && -o pushdminus ) ]]; then
- integer i
- revlines=( $lines )
- for (( i = 1; i <= $#lines; i++ )); do
- lines[$i]="$((i-1)) -- ${revlines[-$i]##[0-9]#[ ]#}"
- done
+if zstyle -T ":completion:${curcontext}:directory-stack" verbose; then
+ # get the list of directories with their canonical number
+ # and turn the lines into an array, removing the current directory
+ lines=("${dirstack[@]}")
+
+ if [[ ( $PREFIX[1] = - && ! -o pushdminus ) ||
+ ( $PREFIX[1] = + && -o pushdminus ) ]]; then
+ integer i
+ revlines=( $lines )
+ for (( i = 1; i <= $#lines; i++ )); do
+ lines[$i]="$((i-1)) -- ${revlines[-$i]##[0-9]#[ ]#}"
+ done
+ else
+ for (( i = 1; i <= $#lines; i++ )); do
+ lines[$i]="$i -- ${lines[$i]##[0-9]#[ ]#}"
+ done
+ fi
+ # get the array of numbers only
+ list=( ${PREFIX[1]}${^lines%% *} )
+ disp=( -ld lines )
else
- for (( i = 1; i <= $#lines; i++ )); do
- lines[$i]="$i -- ${lines[$i]##[0-9]#[ ]#}"
- done
+ list=( ${PREFIX[1]}{0..${#dirstack}} )
+ disp=()
fi
-# get the array of numbers only
-list=(${lines%% *})
-_description expl 'directory stack index'
-compadd "$expl[@]" -ld lines -V dirs -Q - "$list[@]" && ret=0
-[[ -z $compstate[list] ]] && compstate[list]=list && ret=0
-[[ -n $compstate[insert] ]] && compstate[insert]=menu && ret=0
-
-return ret
+
+_all_labels -V directory-stack expl 'directory stack' \
+ compadd "$@" "$disp[@]" -Q - "$list[@]"
diff --git a/Completion/Builtins/_sched b/Completion/Builtins/_sched
index 1e8ae3445..98ecb3642 100644
--- a/Completion/Builtins/_sched
+++ b/Completion/Builtins/_sched
@@ -1,3 +1,23 @@
-#defcomp sched
+#compdef sched
-[[ -position 2 -1 ]] && _normal "$@"
+local expl lines disp
+
+if [[ CURRENT -eq 2 ]]; then
+ if compset -P -; then
+ _wanted -C - jobs || return 1
+
+ lines=(${(f)"$(sched)"})
+ if zstyle -T ":completion:${curcontext}:jobs" verbose; then
+ disp=( -ld lines )
+ else
+ disp=()
+ fi
+ [[ -z $lines ]] || _all_labels jobs expl 'scheduled jobs' \
+ compadd "$disp[@]" - {1..$#lines}
+ return
+ else
+ _message 'time specification'
+ return 1
+ fi
+fi
+compset -n 3 && _normal
diff --git a/Completion/Builtins/_signals b/Completion/Builtins/_signals
index c79350044..aa95a8499 100644
--- a/Completion/Builtins/_signals
+++ b/Completion/Builtins/_signals
@@ -20,17 +20,19 @@ done
[[ "$1" = -(|-) ]] && shift
-if _wanted signals expl signal &&
- { [[ -z "$minus" ]] || ! _style signals prefix-needed ||
+if _wanted signals &&
+ { [[ -z "$minus" ]] ||
+ ! zstyle -T ":completion:${curcontext}:signals" prefix-needed ||
[[ "$PREFIX" = -* ]] } ; then
local disp tmp
- if _style signals prefix-hidden; then
+ if zstyle -t ":completion:${curcontext}:signals" prefix-hidden; then
tmp=( "${(@)signals[1,last]}" )
disp=(-d tmp)
else
disp=()
fi
- compadd "$@" "$expl[@]" "$disp[@]" -M 'm:{a-z}=${A-Z}' - \
- "${minus}${(@)^signals[1,last]}"
+ _all_labels signals expl signal \
+ compadd "$@" "$disp[@]" -M 'm:{a-z}={A-Z}' - \
+ "${minus}${(@)^signals[1,last]}"
fi
diff --git a/Completion/Builtins/_stat b/Completion/Builtins/_stat
index 3cdbb2618..5ba06388b 100644
--- a/Completion/Builtins/_stat
+++ b/Completion/Builtins/_stat
@@ -1,10 +1,20 @@
#compdef stat
+local expl ret=1
+
if [[ "$words[CURRENT-1]" = -[AH] ]]; then
- compgen -A
+ _arrays
else
- [[ "$PREFIX[1]" = + ]] &&
- compadd - +device +inode +mode +nlink +uid +gid +rdev +size \
- +atime +mtime +ctime +blksize +block +link
- _files
+ _tags files options || return 1
+
+ while _tags; do
+ _requested files && _files && ret=0
+ _requested options &&
+ { ! zstyle -T ":completion:${curcontext}:options" prefix-needed ||
+ [[ "$PREFIX[1]" = + || ret -eq 1 ]] } &&
+ _all_labels options expl 'inode element' \
+ compadd - +device +inode +mode +nlink +uid +gid +rdev \
+ +size +atime +mtime +ctime +blksize +block +link
+ (( ret )) || return 0
+ done
fi
diff --git a/Completion/Builtins/_zcompile b/Completion/Builtins/_zcompile
new file mode 100644
index 000000000..5ec6f96ce
--- /dev/null
+++ b/Completion/Builtins/_zcompile
@@ -0,0 +1,22 @@
+#compdef zcompile
+
+local context state line expl
+typeset -A opt_args
+
+_arguments -s \
+ '(-c -m -a)-U[don'\''t expand aliases]' \
+ '(-M)-R[mark as read]' \
+ '(-R)-M[mark as mapped]' \
+ '(-c -z -m -a)-k[ksh-style autoloading]' \
+ '(-c -k -m -a)-z[zsh-style autoloading]' \
+ '(-U -z -k)-c[currently defined functions]' \
+ '(-U -z -k)-m[use names as patterns]' \
+ '(-U -z -k)-a[write autoload functions]' \
+ ':zwc file:_files' \
+ '*:function:->function' && return 0
+
+if (( $+opt_args[-c] )); then
+ _wanted functions expl 'function to write' compadd - ${(k)functions}
+else
+ _wanted file expl 'zsh source file' _files
+fi
diff --git a/Completion/Builtins/_zftp b/Completion/Builtins/_zftp
index 9be9c94db..0d6530dfc 100644
--- a/Completion/Builtins/_zftp
+++ b/Completion/Builtins/_zftp
@@ -1,50 +1,92 @@
-#defpatcomp zf*
-
-# Don't try any more completion after this.
-_compskip=1
+#compdef -p zf*
# Completion for zftp builtin and zf* functions. The functions
-# zfcd_match and zfget_match (used for old-style completion)
+# zfcd_match and zfget_match (also used for old-style completion)
# need to be installed for remote file and directory completion to work.
-local subcom
+# emulate -L zsh
+
+# Don't try any more completion after this.
+_compskip=all
+
+local subcom expl curcontext="${curcontext}"
-if [[ $COMMAND = zftp ]]; then
- if [[ $CURRENT -eq 1 ]]; then
- compadd -m open params user login type ascii binary mode put \
- putat get getat append appendat ls dir local remote mkdir rmdir
+if [[ $words[1] = zftp ]]; then
+ if [[ $CURRENT -eq 2 ]]; then
+ _wanted commands expl sub-command \
+ compadd open params user login type ascii binary mode put \
+ putat get getat append appendat ls dir local remote mkdir rmdir \
+ session rmsession
return
fi
- subcom=$1
+ subcom=$words[2]
+ curcontext="${curcontext/:zftp:/:zftp-${words[2]}:}"
else
- subcom=$COMMAND
+ subcom=$words[1]
fi
case $subcom in
*(cd|ls|dir))
- # complete remote directories; we could be smarter about hiding prefixes
- zfcd_match $PREFIX $SUFFIX
- (( $#reply )) && compadd -m -S/ -q $reply
- ;;
+ # complete remote directories
+ _wanted directories && zfcd_match $PREFIX $SUFFIX
+ ;;
*(get(|at)|gcp|delete|remote))
- # complete remote files
- zfget_match $PREFIX $SUFFIX
- (( $#reply )) && compadd -F fignore -m $reply
- ;;
+ # complete remote files
+ _wanted files && zfget_match $PREFIX $SUFFIX
+ ;;
*(put(|at)|pcp))
- # complete local files
- _files
- ;;
+ # complete local files
+ _wanted files && _files
+ ;;
*(open|anon|params))
- # complete hosts: should do cleverer stuff with user names
- complist -k hosts
- ;;
+ # complete hosts: should do cleverer stuff with user names
+ _wanted hosts && _hosts
+ ;;
+
+ *(goto|mark))
+ # complete bookmarks. First decide if ncftp mode is go.
+ _wanted bookmarks || return 1
+ if [[ $words[2] = -*n* ]]; then
+ if [[ -f ~/.ncftp/bookmarks ]]; then
+ _all_labels bookmarks expl bookmark \
+ compadd - $(awk -F, 'NR > 2 { print $1 }' ~/.ncftp/bookmarks)
+ fi
+ else
+ if [[ -f ${ZFTP_BMFILE:=${ZDOTDIR:-$HOME}/.zfbkmarks} ]]; then
+ _all_labels bookmarks expl bookmark \
+ compadd - $(awk '{print $1}' $ZFTP_BMFILE)
+ fi
+ fi
+ ;;
+
+ *session)
+ # complete sessions, excluding the current one.
+ _wanted sessions expl 'another FTP session' \
+ compadd - ${$(zftp session):#$ZFTP_SESSION}
+ ;;
+
+ *transfer)
+ # complete arguments like sess1:file1 sess2:file2
+ if [[ $PREFIX = *:* ]]; then
+ # complete file in the given session
+ _wanted files || return 1
+ local sess=${PREFIX%%:*} oldsess=$ZFTP_SESSION
+ compset -p $(( $#sess + 1 ))
+ [[ -n $sess ]] && zftp session $sess
+ zfget_match $PREFIX $SUFFIX
+ [[ -n $sess && -n $oldsess ]] && zftp session $oldsess
+ else
+ # note here we can complete the current session
+ _wanted sessions expl 'FTP session' compadd -S : - $(zftp session)
+ fi
+ ;;
*)
- # dunno... try ordinary completion after all.
- unset _compskip
- ;;
+ # dunno... try ordinary completion after all.
+ _compskip=''
+ return 1
+ ;;
esac
diff --git a/Completion/Builtins/_zpty b/Completion/Builtins/_zpty
index b197b4128..d8c77ff2e 100644
--- a/Completion/Builtins/_zpty
+++ b/Completion/Builtins/_zpty
@@ -7,17 +7,17 @@ _arguments -C -s \
'(-d -w -r -L)-b[io to pseudo-terminal blocking]' \
'(-e -b -w -r -L)-d[delete command]:*:name:->name' \
'(-e -b -d -r -L)-w[send string to command]:name:->name:*:strings to write' \
- '(-e -b -d -w -L)-r[read string from command]:name:->name:param:_parameters:*:nothing:_nothing' \
+ '(-e -b -d -w -L *)-r[read string from command]:name:->name:param:_parameters' \
'(-e -b -d -w -r)-L[list defined commands as calls]' \
- '*::args:_normal'
+ '(-r)*::args:_normal'
-if [[ $state = name ]] && _wanted zptynames expl 'zpty command names'; then
+if [[ $state = name ]] && _wanted names; then
list=( ${${(f)"$(zpty)"}#*\) } )
names=( ${list%%:*} )
if zstyle -T ":completion:${curcontext}" verbose; then
zformat -a list ' --' ${${(f)"$(zpty)"}#*\) }
- compadd "$expl[@]" -d list - "$names[@]"
+ _all_labels names expl 'zpty command names' compadd -d list - "$names[@]"
else
- compadd "$expl[@]" - "$names[@]"
+ _all_labels names expl 'zpty command names' compadd - "$names[@]"
fi
fi
diff --git a/Completion/Builtins/_zstyle b/Completion/Builtins/_zstyle
index f072f79ae..cd470598a 100644
--- a/Completion/Builtins/_zstyle
+++ b/Completion/Builtins/_zstyle
@@ -1,7 +1,8 @@
#compdef zstyle
-local curcontext="$curcontext" state ostate line expl ctop
-local nm=$compstat[nmatches]
+local curcontext="$curcontext" state context ostate line expl ctop
+local nm=$compstate[nmatches] mesg
+typeset -A opt_args
typeset -A styles
# Assoc array of styles; the values give the possible top-level
@@ -9,15 +10,18 @@ typeset -A styles
# followed by a colon, followed by a state to enter, empty if none.
styles=(
accept-exact c:bool
+ add-space c:bool
arguments c:
auto-description c:
- cache-path 'c:_path_files -/'
+ break c:
completer c:completer
completions c:
condition c:
- cursor c:bool
+ cursor c:cursor
disable-stat c:bool
+ domains c:
expand c:
+ file-patterns c:filepat
format c:
glob c:
group-name c:
@@ -26,8 +30,9 @@ styles=(
hidden c:bool
hosts c:_hosts
hosts-ports c:host-port
- hosts-ports-users c:host-port-user
- ignored-suffixes c:
+ users-hosts-ports c:user-host-port
+ ignore-parents c:ignorepar
+ ignored-patterns c:
insert-unambiguous c:bool
last-prompt c:bool
list c:listwhen
@@ -36,21 +41,26 @@ styles=(
list-packed c:bool
list-rows-first c:bool
local c:
+ matcher-list c:
max-errors c:
menu c:boolauto
numbers c:bool
original c:bool
- path 'c:_path_files -/'
+ packageset c:packageset
+ path 'c:_wanted directories expl directory _path_files -/'
ports c:_ports
prefix-hidden c:bool
prefix-needed c:bool
prompt c:
remove-all-dups c:bool
+ single-ignored c:single-ignored
sort c:bool
- tag-order c:tag
special-dirs c:sdirs
+ squeeze-slashes c:bool
stop c:stop
+ subst-glob-only c:
substitute c:
+ tag-order c:tag
users c:_users
users-hosts c:user-host
verbose c:bool
@@ -83,9 +93,20 @@ while [[ -n $state ]]; do
case "$ostate" in
contexts)
- if [[ $PREFIX != :*: ]]; then
- _wanted contexts expl context &&
- compadd -P : -S : "$expl[@]" completion zftp
+ if _wanted contexts; then
+ if [[ $PREFIX != :*: ]]; then
+ _all_labels contexts expl context compadd -P : -S : completion zftp
+ elif [[ $PREFIX = :completion:* ]]; then
+ mesg=''
+ case "$PREFIX" in
+ :completion:[^:]#) mesg=function ;;
+ :completion:[^:]#:[^:]#) mesg=completer ;;
+ :completion:[^:]#:[^:]#:[^:]#) mesg='command or context' ;;
+ :completion:[^:]#:[^:]#:[^:]#:[^:]#) mesg=argument ;;
+ :completion:[^:]#:[^:]#:[^:]#:[^:]#:[^:]#) mesg=tag ;;
+ esac
+ [[ -n "$mesg" ]] && _message "$mesg"
+ fi
fi
;;
@@ -96,8 +117,8 @@ while [[ -n $state ]]; do
else
ctop=cz
fi
- _wanted styles expl style &&
- compadd "$expl[@]" - ${(k)styles[(R)[^:]#[$ctop][^:]#:*]}
+ _wanted styles expl style \
+ compadd -M 'r:|-=* r:|=*' - ${(k)styles[(R)[^:]#[$ctop][^:]#:*]}
;;
style-arg)
@@ -105,66 +126,116 @@ while [[ -n $state ]]; do
;;
bool)
- _wanted values expl boolean &&
- compadd "$expl[@]" true false
+ _wanted values expl boolean compadd true false
;;
boolauto)
- _wanted values expl boolean &&
- compadd "$expl[@]" true false auto select
+ _wanted values expl boolean compadd true false auto select
+ ;;
+
+ cursor)
+ if [[ "$words[2]" = *:completion:inc* ]]; then
+ _wanted values expl 'cursor positioning' compadd complete key default
+ elif [[ "$words[2]" = *:completion::* ]]; then
+ _wanted values expl 'cursor positioning' compadd true false
+ else
+ _wanted values expl 'cursor positioning' \
+ compadd complete key default true false
+ fi
;;
completer)
- _wanted values expl completer &&
- compadd "$expl[@]" _complete _approximate _correct _match \
- _expand _list _menu _oldlist
+ _wanted values expl completer \
+ compadd _complete _approximate _correct _match \
+ _expand _list _menu _oldlist _next_tags
;;
- host-port*)
+ user-host-port)
+ if [[ $PREFIX != *[@:]* ]]; then
+ _users -S @
+ elif [[ $PREFIX = *[@:]*[[@:]* ]]; then
+ compset -P 2 '*[:@]'
+ _ports
+ else
+ compset -P 1 '*[:@]'
+ _hosts -S :
+ fi
+ ;;
+
+ host-port)
if [[ $PREFIX != *:* ]]; then
_hosts -S :
- elif [[ $ostate != *user || $PREFIX != *:*:* ]]; then
+ else
compset -P 1 '*:'
_ports
- else
- compset -P 2 '*:'
- _users
fi
;;
listwhen)
- _wanted values expl 'when to list completions' &&
- compadd "$expl[@]" always never sometimes
+ _wanted values expl 'when to list completions' \
+ compadd always never sometimes
+ ;;
+
+ packageset)
+ _wanted values expl 'default package set' \
+ compadd available installed uninstalled
;;
progress)
- _wanted values expl 'progress meter style' &&
- compadd "$expl[@]" none bar percent
+ _wanted values expl 'progress meter style' \
+ compadd none bar percent
;;
sdirs)
- _wanted values expl 'whether to complete . or ..' &&
- compadd "$expl[@]" true false ..
+ _wanted values expl 'whether to complete . or ..' \
+ compadd true false ..
;;
stop)
- _wanted values expl 'when to insert matches' &&
- compadd "$expl[@]" true false verbose
+ _wanted values expl 'when to insert matches' \
+ compadd true false verbose
;;
tag)
- _wanted tags expl tag && compadd "$expl[@]" - $taglist
+ compset -q
+ if compset -P '*:*:'; then
+ _message description
+ elif compset -P '*:'; then
+ _message 'tag alias'
+ else
+ _wanted tags expl tag compadd - $taglist
+ fi
+ ;;
+
+ filepat)
+ if compset -P '*:*:'; then
+ _message description
+ elif compset -P '*:'; then
+ _message tag
+ else
+ _message 'glob patterns'
+ fi
;;
user-host)
- if [[ $PREFIX = *:* ]]; then
- compset -P '*:'
+ if [[ $PREFIX = *[@:]* ]]; then
+ compset -P '*[@:]'
_hosts
else
- _users
+ _users -S @
fi
;;
+ ignorepar)
+ _wanted values expl 'which parents to ignore' \
+ compadd parent pwd .. directory
+ ;;
+
+ single-ignored)
+ _wanted values expl 'how to handle a single ignored match' \
+ compadd - show menu
+ ;;
+
_*)
${=ostate}
;;