diff options
Diffstat (limited to 'Completion/Zsh')
-rw-r--r-- | Completion/Zsh/Command/_cd | 16 | ||||
-rw-r--r-- | Completion/Zsh/Command/_disable | 15 | ||||
-rw-r--r-- | Completion/Zsh/Command/_enable | 14 | ||||
-rw-r--r-- | Completion/Zsh/Command/_fc | 32 | ||||
-rw-r--r-- | Completion/Zsh/Command/_typeset | 28 | ||||
-rw-r--r-- | Completion/Zsh/Context/_math | 4 | ||||
-rw-r--r-- | Completion/Zsh/Context/_zcalc_line | 2 | ||||
-rw-r--r-- | Completion/Zsh/Type/.distfiles | 3 | ||||
-rw-r--r-- | Completion/Zsh/Type/_math_params | 3 | ||||
-rw-r--r-- | Completion/Zsh/Type/_module_math_func | 9 | ||||
-rw-r--r-- | Completion/Zsh/Type/_user_math_func | 9 |
11 files changed, 108 insertions, 27 deletions
diff --git a/Completion/Zsh/Command/_cd b/Completion/Zsh/Command/_cd index 476947f60..a5d328fc5 100644 --- a/Completion/Zsh/Command/_cd +++ b/Completion/Zsh/Command/_cd @@ -51,6 +51,18 @@ else _directory_stack && ret=0 fi + local -a tmpWpath + if [[ $PREFIX = (|*/)../* ]]; then + local tmpprefix + # Use cd in a subshell to properly [not] resolve symlinks + tmpprefix=$(cd ${PREFIX%/*} >&/dev/null && print $PWD) + if [[ -n $tmpprefix ]]; then + tmpWpath=(-W $tmpprefix) + IPREFIX=${IPREFIX}${PREFIX%/*}/ + PREFIX=${PREFIX##*/} + fi + fi + if [[ $PREFIX != (\~|/|./|../)* ]]; then local tmpcdpath alt @@ -88,7 +100,7 @@ else # already handled by _command_names (see _autocd) [[ CURRENT -ne 1 || ( -z "$path[(r).]" && $PREFIX != */* ) ]] && - alt=( "${cdpath+local-}directories:${cdpath+local }directory:_path_files -/" "$alt[@]" ) + alt=( "${cdpath+local-}directories:${cdpath+local }directory:_path_files $tmpWpath -/" "$alt[@]" ) if [[ CURRENT -eq argstart && noopts -eq 0 && $PREFIX = -* ]] && zstyle -t ":completion:${curcontext}:options" complete-options; then @@ -100,7 +112,7 @@ else return ret fi [[ CURRENT -ne 1 ]] && _wanted directories expl directory \ - _path_files -/ && ret=0 + _path_files $tmpWpath -/ && ret=0 return ret fi diff --git a/Completion/Zsh/Command/_disable b/Completion/Zsh/Command/_disable index 3b627fb5f..52b82a6e9 100644 --- a/Completion/Zsh/Command/_disable +++ b/Completion/Zsh/Command/_disable @@ -1,9 +1,16 @@ #compdef disable +local -a ali_arr sali_arr func_arr + +ali_arr=(${(k)aliases} ${(k)galiases}) +sali_arr=(${(k)saliases}) +func_arr=(${(k)functions}) + _arguments -C -s -A "-*" -S \ - "(-f -r -s)-a[act on regular or global aliases]:*:regular or global aliases:(${(k)aliases} ${(k)galiases})" \ - "(-a -r -s)-f[act on functions]:*:functions:(${(k)functions})" \ - "(-a -f -s)-r[act on reserved words]:*:reserved-words:compadd -k reswords" \ - "(-a -f -r)-s[act on suffix aliases]:*:suffix aliases:(${(k)saliases})" \ + "(-f -r -s -p)-a[act on regular or global aliases]:*:regular or global aliases:compadd -k ali_arr" \ + "(-a -r -s -p)-f[act on functions]:*:functions:compadd -k func_arr" \ + "(-a -f -s -p)-r[act on reserved words]:*:reserved-words:compadd -k reswords" \ + "(-a -f -r -p)-s[act on suffix aliases]:*:suffix aliases:compadd -k sali_arr" \ + "(-a -f -r -s)-p[act on pattern characters]:*:pattern characters:compadd -k patchars" \ '-m[treat arguments as patterns]' \ "*:builtin command:(${(k)builtins})" diff --git a/Completion/Zsh/Command/_enable b/Completion/Zsh/Command/_enable index c5f8b2c43..9410651b7 100644 --- a/Completion/Zsh/Command/_enable +++ b/Completion/Zsh/Command/_enable @@ -1,8 +1,16 @@ #compdef enable +local -a ali_arr sali_arr func_arr + +ali_arr=(${(k)dis_aliases} ${(k)dis_galiases}) +sali_arr=(${(k)dis_saliases}) +func_arr=(${(k)dis_functions}) + _arguments -C -s -A "-*" -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:compadd -k dis_reswords" \ + "(-f -r -s -p)-a[act on regular or global aliases]:*:aliases:compadd -k ali_arr" \ + "(-a -r -s -p)-f[act on functions]:*:functions:compadd -k func_arr" \ + "(-a -f -s -p)-r[act on reserved words]:*:reserved-words:compadd -k dis_reswords" \ + "(-a -f -r -p)-s[act on suffix aliases]:*:suffix aliases:compadd -k sali_arr" \ + "(-a -f -r -s)-p[act on pattern characters]:*:pattern characters:compadd -k dis_patchars" \ '-m[treat arguments as patterns]' \ "*:builtin command:(${(k)dis_builtins})" diff --git a/Completion/Zsh/Command/_fc b/Completion/Zsh/Command/_fc index bcbb4928e..2af5980c2 100644 --- a/Completion/Zsh/Command/_fc +++ b/Completion/Zsh/Command/_fc @@ -3,17 +3,21 @@ local fc_common fc_hist fc_r fc_common=( - '(-A -R -W -I)-r[reverse order of the commands]' - '(-A -R -W -I -e)-n[suppress line numbers]' - '(-A -R -W -I)*::commands:_command_names -e' ) + '(-A -R -W -I -p -P)-r[reverse order of the commands]' + '(-A -R -W -I -e -p -P)-n[suppress line numbers]' + '(-A -R -W -I -p -P)*::commands:_command_names -e' ) fc_hist=( - '(-A -R -W -I)-m[treat first argument as a pattern]' - '(-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 -p -p)-m[treat first argument as a pattern]' + '(-A -R -W -I -e -f -E -i -t -p -P)-d[print time-stamps]' + '(-A -R -W -I -e -d -E -i -t -p -P)-f[mm/dd/yyyy format time-stamps]' + '(-A -R -W -I -e -d -f -i -t -p -P)-E[dd.mm.yyyy format time-stamps]' + '(-A -R -W -I -e -d -f -E -t -p -P)-i[yyyy-mm-dd format time-stamps]' + '(-A -R -W -I -e -d -f -E -i -p -P)-t[print time-stamps in specified format]:date format' + '(-A -R -W -I -e -p -P)-D[print elapsed times]' + '(- *)-p[push current history to stack]:history file:_files:history size: :saved history size' + '(- *)-P[pop history from stack]' +) fc_r='(-A -R -W -I -e)-l[list resulting commands on stdout]' @@ -26,11 +30,11 @@ case $service in ;; *) _arguments -s -S \ - '(-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' \ + '(-A -R -W -I -l -n -d -f -E -i -D -p -P)-e[specify editor to invoke]:editor to invoke:_command_names -e' \ + '(-l -m -e -r -n -d -f -E -i -D -A -W -p -P *)-R[read history from file]:history file:_files' \ + '(-l -m -e -r -n -d -f -E -i -D -R -W -p -P *)-A[append history to file]:history file:_files' \ + '(-l -m -e -r -n -d -f -E -i -D -R -A -p -P *)-W[write history to file]:history file:_files' \ + '(-l -m -e -r -n -d -f -E -i -D -A -W -p -P *)-I[read/write new events only]:history file:_files' \ "$fc_common[@]" "$fc_hist[@]" "$fc_r" && return 0 ;; esac diff --git a/Completion/Zsh/Command/_typeset b/Completion/Zsh/Command/_typeset index d44783d64..0920e3fb5 100644 --- a/Completion/Zsh/Command/_typeset +++ b/Completion/Zsh/Command/_typeset @@ -12,7 +12,9 @@ allargs=( F "($fopts -A -E -L -R -T -U -Z -a -i -m)-F[floating point, use fixed point decimal on output]" L "($fopts -A -E -F -i)-L+[left justify and remove leading blanks from value]:width" R "($fopts -A -E -F -i)-R+[right justify and fill with leading blanks]:width" - T "($fopts -A -E -F -a -g -h -i -l -m -t)-T[tie scalar to array]" + T "($fopts -A -E -F -a -g -h -i -l -m -t)-T[tie scalar to array or trace function]" + Tf "($popts -t)-T[trace execution of this function only]" + Tp "($fopts -A -E -F -a -g -h -i -l -m -t)-T[tie scalar to array]" U '(-A -E -F -i)-U[keep array values unique and suppress alias expansion for functions]' Uf '-U[suppress alias expansion for functions]' Up '(-E -F -i)-+U[keep array values unique]' @@ -49,7 +51,7 @@ case ${service} in ;; float) use="EFHghlprtux";; functions) - use="Ukmtuz" + use="UkmTtuz" func=f ;; integer) @@ -64,6 +66,12 @@ esac [[ -z "${words[(r)-*[aA]*]}" ]] || func=p [[ -z "${words[(r)-*f*]}" ]] || func=f +# This function uses whacky features of _arguments which means we +# need to look for options to the command beforehand. +local onopts offopts +onopts=${(j..)${${words[1,CURRENT-1]:#^-*}##-}} +offopts=${(j..)${${words[1,CURRENT-1]:#^+*}##+}} + for ((i=1;i<=$#use;++i)); do args+=( ${allargs[${use[$i]}${${(s::)use[$i]}[(r)[Uut]]:+$func}]} ) done @@ -81,6 +89,22 @@ if [[ "$state" = vars_eq ]]; then funckeys=(${(k)functions}) args=(${args:|funckeys}) _wanted functions expl 'shell function' compadd -a args + elif [[ -n $onopts$offopts ]]; then + if [[ -n $offopts ]]; then + args=(${(f)"$(functions +$offopts)"}) + else + args=(${(k)functions}) + fi + if [[ -n $onopts ]]; then + local -a funckeys + funckeys=(${(f)"$(functions +$onopts)"}) + args=(${args:|funckeys}) + fi + if zstyle -t ":completion:${curcontext}:functions" prefix-needed && + [[ $PREFIX != [_.]* ]]; then + args=(${args:#_*}) + fi + _wanted functions expl 'shell functions' compadd -a args else _functions fi diff --git a/Completion/Zsh/Context/_math b/Completion/Zsh/Context/_math index 278189ebe..f82f1c0fb 100644 --- a/Completion/Zsh/Context/_math +++ b/Completion/Zsh/Context/_math @@ -9,4 +9,6 @@ if [[ "$SUFFIX" = *[^a-zA-Z0-9_]* ]]; then SUFFIX="${SUFFIX%%[^a-zA-Z0-9_]*}" fi -_parameters -g '(integer|float)*' || _parameters +_alternative 'math-parameters:math parameter: _math_params' \ + 'user-math-functions:user math function: _user_math_func' \ + 'module-math-functions:math function from zsh/mathfunc: _module_math_func' diff --git a/Completion/Zsh/Context/_zcalc_line b/Completion/Zsh/Context/_zcalc_line index 76e5b4b25..50fb8c17c 100644 --- a/Completion/Zsh/Context/_zcalc_line +++ b/Completion/Zsh/Context/_zcalc_line @@ -13,7 +13,7 @@ _zcalc_line_escapes() { "eng:engineering (power of 1000) output format" "raw:raw output format" "local:make variables local" - "function:define math function" + "function:define math function (also \:func or \:f)" ) cmds=("\:"${^cmds}) _describe -t command-escapes "command escapes" cmds -Q diff --git a/Completion/Zsh/Type/.distfiles b/Completion/Zsh/Type/.distfiles index 74a4e101d..4011353a0 100644 --- a/Completion/Zsh/Type/.distfiles +++ b/Completion/Zsh/Type/.distfiles @@ -15,10 +15,13 @@ _jobs _jobs_bg _jobs_fg _limits +_math_params +_module_math_func _options _options_set _options_unset _parameters _suffix_alias_files +_user_math_func _vars ' diff --git a/Completion/Zsh/Type/_math_params b/Completion/Zsh/Type/_math_params new file mode 100644 index 000000000..8a4b9e1b6 --- /dev/null +++ b/Completion/Zsh/Type/_math_params @@ -0,0 +1,3 @@ +#autoload + +_parameters -g '(integer|float)*' || _parameters diff --git a/Completion/Zsh/Type/_module_math_func b/Completion/Zsh/Type/_module_math_func new file mode 100644 index 000000000..4df8d9714 --- /dev/null +++ b/Completion/Zsh/Type/_module_math_func @@ -0,0 +1,9 @@ +#autoload + +local expl +local -a funcs + +funcs=(${${${(f)"$(zmodload -Fl zsh/mathfunc 2>/dev/null)"}:#^+f:*}##+f:}) + +_wanted module-math-functions expl 'math function from zsh/mathfunc' \ + compadd -S '(' "$@" -a funcs diff --git a/Completion/Zsh/Type/_user_math_func b/Completion/Zsh/Type/_user_math_func new file mode 100644 index 000000000..16774f70b --- /dev/null +++ b/Completion/Zsh/Type/_user_math_func @@ -0,0 +1,9 @@ +#autoload + +local expl +local -a funcs + +funcs=(${${${(f)"$(functions -M)"}##functions -M }%% *}) + +_wanted user-math-functions expl 'user math function' \ + compadd -S '(' "$@" -a funcs |