forked from zsh-users/zsh
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Peter Stephenson
committed
Apr 1, 2000
1 parent
20c5fbe
commit e025336
Showing
97 changed files
with
17,745 additions
and
3,805 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,23 @@ | ||
#defcomp -default- | ||
#compdef -default- | ||
|
||
# We first try the `compctl's. This is without first (-T) and default (-D) | ||
# completion. If you want them add `-T' and/or `-D' to this command. | ||
# If there is a `compctl' for the command we are working on, we return | ||
# immediatly. If you want to use new style completion anyway, remove the | ||
# `|| return'. Also, you may want to use new style completion if the | ||
# `compctl' didn't produce any matches. In that case remove the `|| return' | ||
# and at the line `[[ -nmatches 0 ]] || return' after `compcall'. | ||
local ctl | ||
|
||
compcall || return | ||
if { zstyle -s ":completion:${curcontext}:" use-compctl ctl || | ||
zmodload -e zsh/compctl } && [[ "$ctl" != (no|false|0|off) ]]; then | ||
local opt | ||
|
||
_files | ||
opt=() | ||
[[ "$ctl" = *first* ]] && opt=(-T) | ||
[[ "$ctl" = *default* ]] && opt=("$opt[@]" -D) | ||
compcall "$opt[@]" || return 0 | ||
fi | ||
|
||
_wanted files || return 1 | ||
|
||
_files && return 0 | ||
|
||
# magicequalsubst allows arguments like <any-old-stuff>=~/foo to do | ||
# file name expansion after the =. In that case, it's natural to | ||
# allow completion to handle file names after any equals sign. | ||
|
||
[[ -o magicequalsubst ]] && compset -P 1 '*=' && _files |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,85 @@ | ||
#autoload | ||
|
||
local expl disp jobs job jids | ||
local expl disp jobs job jids pfx='%' desc how expls | ||
|
||
_wanted jobs || return 1 | ||
|
||
if [[ "$1" = -t ]]; then | ||
zstyle -T ":completion:${curcontext}:jobs" prefix-needed && | ||
[[ "$PREFIX" != %* && compstate[nmatches] -ne 0 ]] && return 1 | ||
shift | ||
fi | ||
zstyle -t ":completion:${curcontext}:jobs" prefix-hidden && pfx='' | ||
zstyle -T ":completion:${curcontext}:jobs" verbose && desc=yes | ||
|
||
if [[ "$1" = -r ]]; then | ||
jids=( "${(@k)jobstates[(R)running*]}" ) | ||
shift | ||
_description expl 'running job' | ||
expls='running job' | ||
elif [[ "$1" = -s ]]; then | ||
jids=( "${(@k)jobstates[(R)running*]}" ) | ||
shift | ||
_description expl 'suspended job' | ||
expls='suspended job' | ||
else | ||
[[ "$1" = - ]] && shift | ||
jids=( "${(@k)jobtexts}" ) | ||
_description expl job | ||
expls=job | ||
fi | ||
|
||
disp=() | ||
jobs=() | ||
for job in "$jids[@]"; do | ||
disp=( "$disp[@]" "${(l:3:: ::%:)job} -- ${jobtexts[$job]}" ) | ||
jobs=( "$jobs[@]" "$job" ) | ||
done | ||
if [[ -n "$desc" ]]; then | ||
disp=() | ||
for job in "$jids[@]"; do | ||
[[ -n "$desc" ]] && | ||
disp=( "$disp[@]" "${pfx}${(r:2:: :)job} -- ${(r:COLUMNS-8:: :)jobtexts[$job]}" ) | ||
done | ||
fi | ||
|
||
zstyle -s ":completion:${curcontext}:jobs" numbers how | ||
|
||
if [[ "$how" = (yes|true|on|1) ]]; then | ||
jobs=( "$jids[@]" ) | ||
else | ||
local texts i text str tmp num max=0 | ||
|
||
compadd "$@" "$expl[@]" -ld disp - "%$^jobs[@]" | ||
# Find shortest unambiguous strings. | ||
|
||
texts=( "$jobtexts[@]" ) | ||
jobs=() | ||
for i in "$jids[@]"; do | ||
text="$jobtexts[$i]" | ||
str="${text%% *}" | ||
if [[ "$text" = *\ * ]]; then | ||
text="${text#* }" | ||
else | ||
text="" | ||
fi | ||
tmp=( "${(@M)texts:#${str}*}" ) | ||
num=1 | ||
while [[ -n "$text" && $#tmp -ge 2 ]]; do | ||
str="${str} ${text%% *}" | ||
if [[ "$text" = *\ * ]]; then | ||
text="${text#* }" | ||
else | ||
text="" | ||
fi | ||
tmp=( "${(@M)texts:#${str}*}" ) | ||
(( num++ )) | ||
done | ||
|
||
[[ num -gt max ]] && max="$num" | ||
|
||
jobs=( "$jobs[@]" "$str" ) | ||
done | ||
|
||
if [[ "$how" = [0-9]## && max -gt how ]]; then | ||
jobs=( "$jids[@]" ) | ||
else | ||
[[ -z "$pfx" && -n "$desc" ]] && disp=( "${(@)disp#%}" ) | ||
fi | ||
fi | ||
|
||
if [[ -n "$desc" ]]; then | ||
_all_labels jobs expl "$expls" compadd "$@" -ld disp - "%$^jobs[@]" | ||
else | ||
_all_labels jobs expl "$expls" compadd "$@" - "%$^jobs[@]" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,56 @@ | ||
#defcomp -subscript- | ||
#compdef -subscript- | ||
|
||
_compalso -math- "$@" | ||
[[ ${(Pt)${COMMAND}} = assoc* ]] && complist -k "( ${(kP)${COMMAND}} )" | ||
local expl | ||
|
||
if [[ "$PREFIX" = :* ]]; then | ||
_wanted characters expl 'character class' \ | ||
compadd -p: -S ':]' alnum alpha blank cntrl digit graph \ | ||
lower print punct space upper xdigit | ||
elif [[ ${(Pt)${compstate[parameter]}} = assoc* ]]; then | ||
local suf | ||
|
||
[[ "$RBUFFER" != \]* ]] && suf=']' | ||
|
||
_wanted association-keys expl 'association key' \ | ||
compadd -S "$suf" - "${(@kP)${compstate[parameter]}}" | ||
elif [[ ${(Pt)${compstate[parameter]}} = array* ]]; then | ||
local list i j ret=1 disp | ||
|
||
_tags indexes parameters | ||
|
||
while _tags; do | ||
if _requested indexes; then | ||
ind=( {1..${#${(P)${compstate[parameter]}}}} ) | ||
if zstyle -T ":completion:${curcontext}:indexes" verbose; then | ||
list=() | ||
for i in "$ind[@]"; do | ||
if [[ "$i" = ${PREFIX}*${SUFFIX} ]]; then | ||
list=( "$list[@]" | ||
"${i}:$(print -D ${(P)${compstate[parameter]}[$i]})" ) | ||
else | ||
list=( "$list[@]" '' ) | ||
fi | ||
done | ||
zformat -a list ' -- ' "$list[@]" | ||
disp=( -d list) | ||
else | ||
disp=() | ||
fi | ||
|
||
if [[ "$RBUFFER" = \]* ]]; then | ||
_all_labels -V indexes expl 'array index' \ | ||
compadd -S '' "$disp[@]" - "$ind[@]" && ret=0 | ||
else | ||
_all_labels -V indexes expl 'array index' \ | ||
compadd -S ']' "$disp[@]" - "$ind[@]" && ret=0 | ||
fi | ||
fi | ||
_requested parameters && _parameters && ret=0 | ||
|
||
(( ret )) || return 0 | ||
done | ||
|
||
return 1 | ||
else | ||
_compalso -math- | ||
fi |
Oops, something went wrong.