diff options
Diffstat (limited to 'Completion/Builtins')
-rw-r--r-- | Completion/Builtins/_aliases | 6 | ||||
-rw-r--r-- | Completion/Builtins/_arrays | 2 | ||||
-rw-r--r-- | Completion/Builtins/_bg_jobs | 5 | ||||
-rw-r--r-- | Completion/Builtins/_bindkey | 6 | ||||
-rw-r--r-- | Completion/Builtins/_builtin | 2 | ||||
-rw-r--r-- | Completion/Builtins/_cd | 3 | ||||
-rw-r--r-- | Completion/Builtins/_command | 4 | ||||
-rw-r--r-- | Completion/Builtins/_compdef | 12 | ||||
-rw-r--r-- | Completion/Builtins/_disable | 8 | ||||
-rw-r--r-- | Completion/Builtins/_enable | 8 | ||||
-rw-r--r-- | Completion/Builtins/_fc | 5 | ||||
-rw-r--r-- | Completion/Builtins/_functions | 2 | ||||
-rw-r--r-- | Completion/Builtins/_hash | 4 | ||||
-rw-r--r-- | Completion/Builtins/_jobs | 5 | ||||
-rw-r--r-- | Completion/Builtins/_kill | 6 | ||||
-rw-r--r-- | Completion/Builtins/_popd | 39 | ||||
-rw-r--r-- | Completion/Builtins/_set | 8 | ||||
-rw-r--r-- | Completion/Builtins/_stat | 3 | ||||
-rw-r--r-- | Completion/Builtins/_trap | 6 | ||||
-rw-r--r-- | Completion/Builtins/_unhash | 9 | ||||
-rw-r--r-- | Completion/Builtins/_wait | 17 | ||||
-rw-r--r-- | Completion/Builtins/_which | 14 | ||||
-rw-r--r-- | Completion/Builtins/_zle | 4 | ||||
-rw-r--r-- | Completion/Builtins/_zmodload | 4 |
24 files changed, 103 insertions, 79 deletions
diff --git a/Completion/Builtins/_aliases b/Completion/Builtins/_aliases index 3e4b789b6..0189d6cf3 100644 --- a/Completion/Builtins/_aliases +++ b/Completion/Builtins/_aliases @@ -2,5 +2,7 @@ local expl -_description expl alias -compgen "$expl[@]" -a +_description expl 'regular alias' +compadd "$expl[@]" - "${(@k)raliases[(R)^?disabled*]}" +_description expl 'global alias' +compadd "$expl[@]" - "${(@k)galiases[(R)^?disabled*]}" diff --git a/Completion/Builtins/_arrays b/Completion/Builtins/_arrays index 20681f527..a2aa813b6 100644 --- a/Completion/Builtins/_arrays +++ b/Completion/Builtins/_arrays @@ -3,4 +3,4 @@ local expl _description expl array -compgen "$expl[@]" -A +compadd "$expl[@]" - "${(@k)parameters[(R)*array*]}" diff --git a/Completion/Builtins/_bg_jobs b/Completion/Builtins/_bg_jobs index 65f21b483..6d6a8fcc4 100644 --- a/Completion/Builtins/_bg_jobs +++ b/Completion/Builtins/_bg_jobs @@ -1,6 +1,3 @@ #compdef bg -local expl - -_description expl 'suspended job' -compgen "$expl[@]" -z -P '%' +_job -s -P '%' diff --git a/Completion/Builtins/_bindkey b/Completion/Builtins/_bindkey index 891e2cedb..3f964e704 100644 --- a/Completion/Builtins/_bindkey +++ b/Completion/Builtins/_bindkey @@ -3,7 +3,7 @@ # Normally, this completes names of zle widgets, whether the builtin ones # or ones defined by the user. Note that a - allows a wildcard before it, # so h-b-s-b will complete to history-beginning-search-backward. You -# can alter this by removing the -M ... from the second compgen. +# can alter this by removing the -M ... from the second compadd. # # Where appropriate, will complete keymaps instead of widgets. @@ -11,8 +11,8 @@ local expl if [[ "$words[2]" = -*[DAN]* || "$words[CURRENT-1]" = -*M ]]; then _description expl keymap - compadd "$expl[@]" - $(bindkey -l) + compadd "$expl[@]" - "$zlekeymaps[@]" else _description expl widget - compgen "$expl[@]" -b -M 'r:|-=* r:|=*' + compadd "$expl[@]" -M 'r:|-=* r:|=*' - "${(@k)zlewidgets}" fi diff --git a/Completion/Builtins/_builtin b/Completion/Builtins/_builtin index f925b88a8..06ef1c246 100644 --- a/Completion/Builtins/_builtin +++ b/Completion/Builtins/_builtin @@ -8,5 +8,5 @@ else local expl _description expl 'builtin command' - compgen "$expl[@]" -eB + compadd "$expl[@]" "$@" - "${(k@)builtins[(R)^?disabled*]}" fi diff --git a/Completion/Builtins/_cd b/Completion/Builtins/_cd index 838b1af24..b407b5a85 100644 --- a/Completion/Builtins/_cd +++ b/Completion/Builtins/_cd @@ -11,8 +11,7 @@ # it's not a lot of use. If you don't type the + or - it will # complete directories as normal. -emulate -L zsh -setopt extendedglob nonomatch +setopt localoptions nonomatch local expl diff --git a/Completion/Builtins/_command b/Completion/Builtins/_command index 4ae274f1f..9f54aae80 100644 --- a/Completion/Builtins/_command +++ b/Completion/Builtins/_command @@ -6,6 +6,6 @@ if [[ CURRENT -ge 3 ]]; then else local expl - _description expl command - compgen "$expl[@]" -em + _description expl 'external command' + compadd "$expl[@]" "$@" - "${(k@)commands}" fi diff --git a/Completion/Builtins/_compdef b/Completion/Builtins/_compdef index 1df5758b3..4208c2689 100644 --- a/Completion/Builtins/_compdef +++ b/Completion/Builtins/_compdef @@ -1,6 +1,6 @@ #compdef compdef -local func base=2 +local expl func base=2 while [[ $words[base] = -* ]]; do case $words[base] in @@ -12,11 +12,13 @@ while [[ $words[base] = -* ]]; do done if [ "$delete" ]; then - compadd ${(k)_comps} + _description expl 'completed command' + compadd "$expl[@]" - ${(k)_comps} else - if [[ CURRENT -eq base ]]; then - for func in ${^~fpath:/.}/_(|*[^~])(N:t); compadd -P_ - ${func#_} + if [[ CURRENT -eq base ]]; then + _description expl 'completion function' + compadd "$expl[@]" - ${^fpath:/.}/_(|*[^~])(N:t) else - compgen -c + _command_names fi fi diff --git a/Completion/Builtins/_disable b/Completion/Builtins/_disable index b219f4b7e..fe6b991b2 100644 --- a/Completion/Builtins/_disable +++ b/Completion/Builtins/_disable @@ -4,19 +4,19 @@ local prev="$words[CURRENT-1]" ret=1 expl if [[ "$prev" = -*a* ]]; then _description expl alias - compgen "$expl[@]" -ea && ret=0 + compadd "$expl[@]" "$@" - "${(k@)aliases[(R)^?disabled*]}" && ret=0 fi if [[ "$prev" = -*f* ]]; then _description expl 'shell function' - compgen "$expl[@]" -eF && ret=0 + compadd "$expl[@]" "$@" - "${(k@)functions[(R)^?disabled*]}" && ret=0 fi if [[ "$prev" = -*r* ]]; then _description expl 'reserved word' - compgen "$expl[@]" -ew && ret=0 + compadd "$expl[@]" "$@" - "${(k@)reswords[(R)^?disabled*]}" && ret=0 fi if [[ "$prev" != -* ]]; then _description expl 'builtin command' - compgen "$expl[@]" -eB && ret=0 + compadd "$expl[@]" "$@" - "${(k@)builtins[(R)^?disabled*]}" && ret=0 fi return ret diff --git a/Completion/Builtins/_enable b/Completion/Builtins/_enable index a698a3895..b4f0356bc 100644 --- a/Completion/Builtins/_enable +++ b/Completion/Builtins/_enable @@ -4,19 +4,19 @@ local prev="$words[CURRENT-1]" ret=1 expl if [[ "$prev" = -*a* ]]; then _description expl alias - compgen "$expl[@]" -da && ret=0 + compadd "$expl[@]" "$@" - "${(k@)aliases[(R)?disabled*]}" && ret=0 fi if [[ "$prev" = -*f* ]]; then _description expl 'shell function' - compgen "$expl[@]" -dF && ret=0 + compadd "$expl[@]" "$@" - "${(k@)functions[(R)?disabled*]}" && ret=0 fi if [[ "$prev" = -*r* ]]; then _description expl 'reserved word' - compgen "$expl[@]" -dw && ret=0 + compadd "$expl[@]" "$@" - "${(k@)reswords[(R)?disabled*]}" && ret=0 fi if [[ "$prev" != -* ]]; then _description expl 'builtin command' - compgen "$expl[@]" -dB && ret=0 + compadd "$expl[@]" "$@" - "${(k@)builtins[(R)?disabled*]}" && ret=0 fi return ret diff --git a/Completion/Builtins/_fc b/Completion/Builtins/_fc index 8d5c82763..c2eaab7bb 100644 --- a/Completion/Builtins/_fc +++ b/Completion/Builtins/_fc @@ -1,10 +1,9 @@ #compdef fc -local prev="$words[CURRENT-1]" expl +local prev="$words[CURRENT-1]" if [[ "$prev" = -*e ]]; then - _description expl command - compgen "$expl[@]" -c + _command_names -e elif [[ "$prev" = -[ARWI]## ]]; then _files fi diff --git a/Completion/Builtins/_functions b/Completion/Builtins/_functions index 7aa30b7bc..d5f32d2e3 100644 --- a/Completion/Builtins/_functions +++ b/Completion/Builtins/_functions @@ -3,4 +3,4 @@ local expl _description expl 'shell function' -compgen "$expl[@]" -F +compadd "$expl[@]" "$@" - "${(k@)functions[(R)^?disabled*]}" diff --git a/Completion/Builtins/_hash b/Completion/Builtins/_hash index c8169c590..c06d63699 100644 --- a/Completion/Builtins/_hash +++ b/Completion/Builtins/_hash @@ -7,11 +7,11 @@ if [[ "$words[2]" = -*d* ]]; then _path_files -g '*(-/)' else _description expl 'named directory' - compgen "$expl[@]" -n -q -S '=' + compadd "$expl[@]" -q -S '=' - "${(@k)nameddirs}" fi elif compset -P 1 '*\='; then _files -/g '*(*)' else _description expl command - compgen "$expl[@]" -m -q -S '=' + compadd "$expl[@]" -q -S '=' - "${(@k)commands}" fi diff --git a/Completion/Builtins/_jobs b/Completion/Builtins/_jobs index b1ff31b4a..c17b73c92 100644 --- a/Completion/Builtins/_jobs +++ b/Completion/Builtins/_jobs @@ -1,6 +1,3 @@ #compdef disown fg jobs -local expl - -_description expl job -compgen "$expl[@]" -j -P '%' +_job -P '%' diff --git a/Completion/Builtins/_kill b/Completion/Builtins/_kill index da70cf753..b79bfd6c0 100644 --- a/Completion/Builtins/_kill +++ b/Completion/Builtins/_kill @@ -8,9 +8,9 @@ if compset -P 1 -; then else local ret=1 - _description expl job - compgen "$expl[@]" -P '%' -j && ret=0 - list=("${(@Mr:COLUMNS-1:)${(f@)$(ps ${=compconfig[ps_listargs]:-$=compconfig[ps_args]} 2>/dev/null)}[2,-1]:#[ ]#${PREFIX}[0-9]#${SUFFIX}[ ]*}") + _job && ret=0 + + list=("${(@M)${(f@)$(ps ${=compconfig[ps_listargs]:-$=compconfig[ps_args]} 2>/dev/null)}[2,-1]:#[ ]#${PREFIX}[0-9]#${SUFFIX}[ ]*}") _description expl 'process ID' compadd "$expl[@]" -ld list - ${${${(f)"$(ps $=compconfig[ps_args] 2>/dev/null)"}[2,-1]## #}%% *} && ret=0 diff --git a/Completion/Builtins/_popd b/Completion/Builtins/_popd index 9054befb7..07dc4a87f 100644 --- a/Completion/Builtins/_popd +++ b/Completion/Builtins/_popd @@ -5,6 +5,45 @@ # way round if pushdminus is set). Note that this function is also called # from _cd for cd and pushd. +setopt localoptions nonomatch + +[[ $PREFIX = [-+]* ]] || return 1 + +local expl list lines revlines ret=1 i + +IPREFIX=$PREFIX[1] +PREFIX=$PREFIX[2,-1] + +# get the list of directories with their canonical number +# and turn the lines into an array, removing the current directory +lines=( "$dirstack[@]" ) +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]}" + done +else + for (( i = 1; i <= $#lines; i++ )); do + lines[$i]="$i -- ${lines[$i]}" + done +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 +#compdef popd + +# This just completes the numbers after +, showing the full directory list +# with numbers. For - we do the same thing, but reverse the numbering (other +# 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 diff --git a/Completion/Builtins/_set b/Completion/Builtins/_set index 297a15d3b..b96eb0efb 100644 --- a/Completion/Builtins/_set +++ b/Completion/Builtins/_set @@ -1,11 +1,9 @@ #compdef set -local prev="$words[CURRENT-1]" expl +local prev="$words[CURRENT-1]" if [[ "$prev" = [-+]o ]]; then - _description expl 'zsh option' - compgen "$expl[@]" -o + _options elif [[ "$prev" = -A ]]; then - _description expl array - compgen "$expl[@]" -A + _arrays fi diff --git a/Completion/Builtins/_stat b/Completion/Builtins/_stat index 5a39e56e5..322f042ec 100644 --- a/Completion/Builtins/_stat +++ b/Completion/Builtins/_stat @@ -3,8 +3,7 @@ local expl if [[ "$words[CURRENT-1]" = -[AH] ]]; then - _description expl array - compgen "$expl[@]" -A + _arrays else _description expl 'inode element' [[ "$PREFIX[1]" = + ]] && diff --git a/Completion/Builtins/_trap b/Completion/Builtins/_trap index d6fc7b388..0f0209914 100644 --- a/Completion/Builtins/_trap +++ b/Completion/Builtins/_trap @@ -3,9 +3,9 @@ local expl if [[ CURRENT -eq 2 ]]; then - _description expl command - compgen "$expl[@]" -c + compset -q + _normal else _description expl signal - compgen "$expl[@]" -k signals + compadd "$expl[@]" - "$signals[@]" fi diff --git a/Completion/Builtins/_unhash b/Completion/Builtins/_unhash index eb1787936..dfebd5399 100644 --- a/Completion/Builtins/_unhash +++ b/Completion/Builtins/_unhash @@ -4,19 +4,18 @@ local fl="$words[2]" ret=1 expl if [[ "$fl" = -*d* ]]; then _description expl 'named directory' - compgen "$expl[@]" -n && ret=0 + compadd "$expl[@]" - "${(@k)nameddirs}" && ret=0 fi if [[ "$fl" = -*a* ]]; then _description expl alias - compgen "$expl[@]" -a && ret=0 + compadd "$expl[@]" - "${(@k)aliases}" && ret=0 fi if [[ "$fl" = -*f* ]]; then _description expl 'shell function' - compgen "$expl[@]" -F && ret=0 + compadd "$expl[@]" - "${(@k)functions}" && ret=0 fi if [[ "$fl" != -* ]]; then - _description expl command - compgen "$expl[@]" -m && ret=0 + _command_names -e && ret=0 fi return ret diff --git a/Completion/Builtins/_wait b/Completion/Builtins/_wait index 17a030dad..68ca187e8 100644 --- a/Completion/Builtins/_wait +++ b/Completion/Builtins/_wait @@ -1,21 +1,10 @@ #compdef wait -# This uses two configuration keys: -# -# ps_args -# This can be set to options of the ps(1) command that should be -# used when invoking it to get the pids to complete. -# -# ps_listargs -# This defaults to the value of the `ps_args' key and defines -# options for the ps command that are to be used when creating -# the list to display during completion. - local list ret=1 expl -_description expl job -compgen "$expl[@]" -P '%' -j && ret=0 -list=("${(@Mr:COLUMNS-1:)${(f)$(ps ${=compconfig[ps_listargs]:-$=compconfig[ps_args]} 2>/dev/null)}[2,-1]:#[ ]#${PREFIX}[0-9]#${SUFFIX}[ ]*}") +_job -P '%' && ret=0 + +list=("${(@M)${(f)$(ps ${=compconfig[ps_listargs]:-$=compconfig[ps_args]} 2>/dev/null)}[2,-1]:#[ ]#${PREFIX}[0-9]#${SUFFIX}[ ]*}") _description expl 'process ID' compadd "$expl[@]" -ld list - ${${${(f)"$(ps $=compconfig[ps_args] 2>/dev/null)"}[2,-1]## #}%% *} && ret=0 diff --git a/Completion/Builtins/_which b/Completion/Builtins/_which index d67af7316..30d20ab36 100644 --- a/Completion/Builtins/_which +++ b/Completion/Builtins/_which @@ -2,9 +2,13 @@ local expl -_description expl command -compgen "$expl[@]" -c -_description expl alias -compgen "$expl[@]" -a +_description expl 'external command' +compadd "$expl[@]" "$@" - "${(k@)commands}" && ret=0 +_description expl 'builtin command' +compadd "$expl[@]" "$@" - "${(k@)builtins[(R)^?disabled*]}" && ret=0 _description expl 'shell function' -compgen "$expl[@]" -F +compadd "$expl[@]" "$@" - "${(k@)functions[(R)^?disabled*]}" && ret=0 +_description expl 'alias' +compadd "$expl[@]" "$@" - "${(k@)raliases[(R)^?disabled*]}" && ret=0 +_description expl 'reserved word' +compadd "$expl[@]" "$@" - "${(k@)reswords[(R)^?disabled*]}" && ret=0 diff --git a/Completion/Builtins/_zle b/Completion/Builtins/_zle index 06e8fcad3..327d67c62 100644 --- a/Completion/Builtins/_zle +++ b/Completion/Builtins/_zle @@ -4,8 +4,8 @@ local expl if [[ "$words[2]" = -N && CURRENT -eq 3 ]]; then _description expl 'widget shell function' - compgen "$expl[@]" -F + compadd "$expl[@]" "$@" - "${(k@)functions[(R)^?disabled*]}" && ret=0 else _description expl widget - compgen "$expl[@]" -b + compadd "$expl[@]" - "${(@k)zlewidgets}" fi diff --git a/Completion/Builtins/_zmodload b/Completion/Builtins/_zmodload index 429128517..a0d5987c4 100644 --- a/Completion/Builtins/_zmodload +++ b/Completion/Builtins/_zmodload @@ -4,10 +4,10 @@ local fl="$words[2]" expl if [[ "$fl" = -*(a*u|u*a)* || "$fl" = -*a* && CURRENT -ge 4 ]]; then _description expl 'builtin command' - compgen "$expl[@]" -B + compadd "$expl[@]" "$@" - "${(k@)builtins[(R)^?disabled*]}" && ret=0 elif [[ "$fl" = -*u* ]]; then _description expl module - compadd "$expl[@]" - $(zmodload) + compadd "$expl[@]" - "${(@k)modules}" else _description expl 'module file' compadd "$expl[@]" - ${^module_path}/*.s[ol](N:t:r) |