diff options
Diffstat (limited to 'Completion/Zsh/Command')
-rw-r--r-- | Completion/Zsh/Command/_compadd | 52 | ||||
-rw-r--r-- | Completion/Zsh/Command/_fc | 48 | ||||
-rw-r--r-- | Completion/Zsh/Command/_print | 17 | ||||
-rw-r--r-- | Completion/Zsh/Command/_setopt | 5 | ||||
-rw-r--r-- | Completion/Zsh/Command/_strftime | 12 | ||||
-rw-r--r-- | Completion/Zsh/Command/_zmodload | 2 | ||||
-rw-r--r-- | Completion/Zsh/Command/_zpty | 7 |
7 files changed, 107 insertions, 36 deletions
diff --git a/Completion/Zsh/Command/_compadd b/Completion/Zsh/Command/_compadd new file mode 100644 index 000000000..03fed1854 --- /dev/null +++ b/Completion/Zsh/Command/_compadd @@ -0,0 +1,52 @@ +#compdef compadd + +local curcontext="$curcontext" state line ret=1 +typeset -A opt_args + +_arguments -C -s -S -A "-*" \ + '-P+[specify prefix]:prefix' \ + '-S+[specify suffix]:suffix' \ + '-p+[specify hidden prefix]:hidden prefix' \ + '-s+[specify hidden suffix]:hidden suffix' \ + '-i+[specify ignored prefix]:ignored prefix' \ + '-I+[specify ignored suffix]:ignored suffix' \ + '(-k)-a[matches are elements of specified arrays]' \ + '(-a)-k[matches are keys of specified associative arrays]' \ + '-d+[specify display strings]:array:_parameters -g "*array*"' \ + '-l[list display strings one per line, not in columns]' \ + '-o[order matches by display string not by match string]' \ + '(-1 -E)-J+[specify match group]:group' \ + '-V+[specify unsorted match group]:group' \ + '(-J -E)-1[remove only consecutive duplicates from group]' \ + '-2[preserve all duplicates]' \ + '(-x)-X[specify explanation]:explanation' \ + '(-X)-x[specify unconditional explanation]:explanation' \ + '-q[make suffix autoremovable]' \ + '-r+[specify character class for suffix autoremoval]:character class' \ + '-R+[specify function for suffix autoremoval]:function:_functions' \ + '-f[mark matches as being files]' \ + '-e[mark matches as being parameters]' \ + '-W[specify location for matches marked as files]' \ + '-F+[specify array of ignore patterns]:array:_parameters -g "*array*"' \ + '-Q[disable quoting of matchines]' \ + '*-M[specify matching specifications]' \ + '-n[hide matches in completion listing]' \ + '-U[disable internal matching of completion candidates]' \ + '-O+[populate array with matches instead of adding them]:array:_parameters -g "*array*"' \ + '-A+[populate array with expanded matches instead of adding them]:array:_parameters -g "*array*"' \ + '-D+[delete elements from array corresponding to non-matching candidates]:array:_parameters -g "*array*"' \ + '-C[add special match that expands to all other matches]' \ + '(-1 -J)-E+[add specified number of display only matches]:number' \ + '*:candidate:->candidates' && ret=0 + +if [[ -n $state ]]; then + if (( $+opt_args[-a] )); then + _parameters -g "*array*" && ret=0 + elif (( $+opt_args[-k] )); then + _parameters -g "*assoc*" && ret=0 + else + _message -e candidate candidates + fi +fi + +return ret diff --git a/Completion/Zsh/Command/_fc b/Completion/Zsh/Command/_fc index c2987211e..68456cc3d 100644 --- a/Completion/Zsh/Command/_fc +++ b/Completion/Zsh/Command/_fc @@ -1,7 +1,7 @@ #compdef fc history r local curcontext="$curcontext" state state_descr line ret=1 -local list events num cmd +local events num cmd sep typeset -A opt_args local fc_common fc_hist fc_r @@ -12,8 +12,10 @@ words=( "${(@)words[1,CURRENT-1]:#*=*}" "${(@)words[CURRENT,-1]}" ) fc_common=( -s -S - '(-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 -p -P)-I[include internal (new) events only]' + '(-A -R -W -p -P)-L[include local events only]' + '(-A -R -W -p -P)-r[reverse order of the events]' + '(-A -R -W -e -p -P)-n[suppress line numbers]' ) if [[ -n ${words[(r)-[pa](|[ap])]} ]]; then @@ -32,20 +34,20 @@ else fi fc_hist=( - '(-A -R -W -I -a -p -P 2)-m[treat argument as a pattern]' - '(-A -R -W -I -e -f -E -i -t -a -p -P)-d[print time-stamps]' - '(-A -R -W -I -e -d -E -i -t -a -p -P)-f[mm/dd/yyyy format time-stamps]' - '(-A -R -W -I -e -d -f -i -t -a -p -P)-E[dd.mm.yyyy format time-stamps]' - '(-A -R -W -I -e -d -f -E -t -a -p -P)-i[yyyy-mm-dd format time-stamps]' - '(-A -R -W -I -e -d -f -E -i -a -p -P)-t[print time-stamps in specified format]:date format' - '(-A -R -W -I -e -a -p -P)-D[print elapsed times]' + '(-A -R -W -a -p -P 2)-m[treat argument as a pattern]' + '(-A -R -W -e -f -E -i -t -a -p -P)-d[print time-stamps]' + '(-A -R -W -e -d -E -i -t -a -p -P)-f[mm/dd/yyyy format time-stamps]' + '(-A -R -W -e -d -f -i -t -a -p -P)-E[dd.mm.yyyy format time-stamps]' + '(-A -R -W -e -d -f -E -t -a -p -P)-i[yyyy-mm-dd format time-stamps]' + '(-A -R -W -e -d -f -E -i -a -p -P)-t[print time-stamps in specified format]:date format' + '(-A -R -W -e -a -p -P)-D[print elapsed times]' '(-A -R -W -I -e -d -f -i -l -m -n -r -D -E -t -P)-a[with -p, automatically pop history on function return]' '(-A -R -W -I -e -d -f -i -l -m -n -r -D -E -t -P)-p[push current history to stack]' '(- *)-P[pop history from stack]' ) -fc_r='(-A -R -W -I -e)-l[list resulting commands on stdout]' +fc_r='(-A -R -W -e)-l[list resulting commands on stdout]' case $service in history) @@ -56,31 +58,29 @@ case $service in ;; *) _arguments "$fc_common[@]" "$fc_hist[@]" "$fc_r" \ - '(-A -R -W -I -a -l -n -d -f -E -i -r -t -D -p -P)-e+[specify editor to invoke]:editor to invoke:_command_names -e' \ - '(-a -l -m -e -r -n -d -f -t -E -i -R -D -A -W -p -P *)-'{\ + '(-A -R -W -a -l -n -d -f -E -i -r -t -D -p -P)-e+[specify editor to invoke]:editor to invoke:_command_names -e' \ + '(-a -l -L -m -e -r -n -d -f -t -E -i -R -D -A -W -p -P *)-'{\ 'R[read history from file]',\ 'A[append history to file]',\ -'W[write history to file]',\ -'I[read/write new events only]'} && ret=0 +'W[write history to file]'} && ret=0 ;; esac if [[ -n $state ]]; then + zstyle -s ":completion:${curcontext}:" list-separator sep || sep=-- if [[ -z ${line:#*=*} ]] && compset -P '*='; then _message -e replacements 'replacement' elif [[ -prefix [0-9] ]]; then - events=( ${(ps.\0.)"$(printf '%s:%s\0' ${(kv)history})"} ) - zformat -a list " -- " "$events[@]" - _wanted -2V events expl "$state_descr" compadd -M "B:0=" -ld list - \ - "${events[@]%%:*}" + events=( ${(0)"$(printf "%-${#HISTNO}.${#HISTNO}s $sep %s\0" "${(kv)history[@]}")"} ) + _wanted -2V events expl "$state_descr" compadd -M "B:0=" -ld events - \ + "${events[@]%% *}" elif [[ -prefix - ]]; then - for num cmd in ${(kv)history}; do + for num cmd in "${(kv@)history}"; do (( num=num - HISTNO )) - events+=( $num:$cmd ) + events+=( "${(r.1+$#HISTNO.)num} $sep $cmd" ) done - zformat -a list " -- " "$events[@]" - _wanted -2V events expl "$state_descr" compadd -ld list - \ - "${events[@]%%:*}" + _wanted -2V events expl "$state_descr" compadd -ld events - \ + "${events[@]%% *}" else _wanted events expl "$state_descr" compadd -S '' - \ ${${history%%[=[:IFS:]]*}:#[0-9-]*} || _guard "[0-9]#" event diff --git a/Completion/Zsh/Command/_print b/Completion/Zsh/Command/_print index 405393355..1eba13e88 100644 --- a/Completion/Zsh/Command/_print +++ b/Completion/Zsh/Command/_print @@ -11,7 +11,7 @@ if [[ $service = print ]]; then pflag='(-s -u -z)-p[print arguments to input of coprocess]' if [[ -n ${words[1,CURRENT][(r)-*P*]} ]]; then - rest='*: :_ps1234' + rest='*: :->prompt' else rest='*: :_default' fi @@ -48,16 +48,17 @@ if [[ $state = printf ]]; then fi if [[ $state = printfformat ]]; then - if [[ ${(Q)PREFIX} = *%((-|)<->|[-#0 +*.])# ]]; then + if [[ ${(Q)PREFIX} = *%[0-9\$#\ +*.\'-]# ]]; then local -a specs specs=( '#:alternate form' - '0:zeropad to length n' + '0:zero pad to length' '-:left adjust result' ' :leave one space in front of positive number from signed conversion' '+:always place sign before a number from signed conversion' '*:field width in next argument' '.:precision' + "':thousand separators" 'c:print the first character of the argument' 's:print the argument as a string' {d,i}':signed decimal number or with leading " numeric value of following character' @@ -73,12 +74,16 @@ if [[ $state = printfformat ]]; then 'q:as %s but shell quote result' ) compset -P "*" - _describe -t print-format-specifier 'print format specifier' specs -S '' - _message -e print-format-specifier 'number' + _describe -t print-format-specifiers 'print format specifier' specs -S '' + _message -e print-format-specifiers 'number' else - _describe -t print-format-specifier 'print format specifier' '(%)' -S '' + _wanted print-format-specifiers expl 'print format specifier' compadd -S '' % fi ret=0 +elif [[ $state = prompt ]]; then + _default && ret=0 + # complete prompt specifiers without interfering too much with default completion + (( $#compstate[unambiguous] <= $#PREFIX || ! $#PREFIX )) && _ps1234 && ret=0 fi return ret diff --git a/Completion/Zsh/Command/_setopt b/Completion/Zsh/Command/_setopt index fb38d1da6..86c0965f9 100644 --- a/Completion/Zsh/Command/_setopt +++ b/Completion/Zsh/Command/_setopt @@ -2,8 +2,9 @@ local expl ret=1 local -a onopts offopts -onopts=( ${(k)_comp_caller_options[(R)on]} ) -offopts=( ${(k)_comp_caller_options[(R)off]} ) +onopts=( ${(k)_comp_caller_options[(R)on]} printexitvalue ) +offopts=( ${(k)_comp_caller_options[(R)off]} printexitvalue ) +typeset -U onopts offopts case $service in setopt) onopts=(no$onopts) ;; unsetopt) offopts=(no$offopts) ;; diff --git a/Completion/Zsh/Command/_strftime b/Completion/Zsh/Command/_strftime new file mode 100644 index 000000000..0be7b078d --- /dev/null +++ b/Completion/Zsh/Command/_strftime @@ -0,0 +1,12 @@ +#compdef strftime + +local ret=1 expl + +_arguments -S -A '-*' -s \ + '-q[run quietly]' \ + '-r[reverse lookup using strptime]' \ + '-s+[assign result to parameter]:param:_parameters' \ + '1:format: _date_formats' \ + '2:epoch time (or date string with -r)' && ret=0 + +return ret diff --git a/Completion/Zsh/Command/_zmodload b/Completion/Zsh/Command/_zmodload index e144b981e..57fb990e9 100644 --- a/Completion/Zsh/Command/_zmodload +++ b/Completion/Zsh/Command/_zmodload @@ -68,7 +68,7 @@ else _requested loadedmodules expl 'loaded modules' \ compadd -k 'modules[(R)loaded]' && ret=0 _requested files expl 'module file' \ - _files -W module_path -/g '*.(dll|s[ol]|bundle)(:r)' && ret=0 + _files -W module_path -g '*.(dll|s[ol]|bundle)(:r)' && ret=0 _requested aliases expl 'module alias' \ compadd "$suf[@]" -k 'modules[(R)alias*]' && ret=0 done diff --git a/Completion/Zsh/Command/_zpty b/Completion/Zsh/Command/_zpty index ef4ac4bb1..99251aa0a 100644 --- a/Completion/Zsh/Command/_zpty +++ b/Completion/Zsh/Command/_zpty @@ -1,6 +1,6 @@ #compdef zpty -local state line list names expl curcontext="$curcontext" +local state line list names expl sep curcontext="$curcontext" typeset -A opt_args _arguments -C -s -S \ @@ -50,8 +50,9 @@ if [[ $state = name ]]; then fi list=( ${${(f)"$(zpty)"}#*\) } ) names=( ${list%%:*} ) - if zstyle -T ":completion:${curcontext}" verbose; then - zformat -a list ' --' ${${(f)"$(zpty)"}#*\) } + if zstyle -T ":completion:${curcontext}:" verbose; then + zstyle -s ":completion:${curcontext}:" list-separator sep || sep=-- + zformat -a list " $sep" ${${(f)"$(zpty)"}#*\) } _wanted names expl 'zpty command name' compadd -d list -a names else _wanted names expl 'zpty command name' compadd -a names |