mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-11-01 06:20:55 +01:00
zsh-workers/8537
This commit is contained in:
parent
cf2aed3500
commit
d9f2398db5
7 changed files with 51 additions and 45 deletions
|
|
@ -23,9 +23,7 @@ shift OPTIND-1
|
|||
|
||||
# Do the tests. `showd' is set if the descriptions should be shown.
|
||||
|
||||
_tags -c "$cmd" -f "$func" "$type"
|
||||
|
||||
_tags || return 1
|
||||
_tags -i -c "$cmd" -f "$func" "$type" || return 1
|
||||
|
||||
[[ "$tags" = *:${type}\[*describe*\]* ]] && showd=yes
|
||||
|
||||
|
|
|
|||
|
|
@ -6,8 +6,7 @@ if compvalues -i "$@"; then
|
|||
|
||||
if ! compvalues -D descr action; then
|
||||
|
||||
_tags value
|
||||
_tags || return 1
|
||||
_tags -i value || return 1
|
||||
|
||||
compvalues -V noargs args opts
|
||||
|
||||
|
|
@ -52,8 +51,7 @@ if compvalues -i "$@"; then
|
|||
fi
|
||||
fi
|
||||
|
||||
_tags argument
|
||||
_tags || return 1
|
||||
_tags -i argument || return 1
|
||||
|
||||
_description expl "$descr"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,24 +1,21 @@
|
|||
#compdef kill
|
||||
|
||||
local list expl
|
||||
local tags list expl
|
||||
|
||||
if compset -P 1 -; then
|
||||
|
||||
_tags -i signal || return 1
|
||||
|
||||
_description expl signal
|
||||
compadd "$expl[@]" $signals[1,-3]
|
||||
else
|
||||
local tags ret=1
|
||||
local ret=1
|
||||
|
||||
_tags job process
|
||||
|
||||
while _tags; do
|
||||
[[ "$tags" = *:job:* ]] && _jobs && ret=0
|
||||
if [[ "$tags" = *:process:* ]]; then
|
||||
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
|
||||
fi
|
||||
[[ "$tags" = *:job:* ]] && _jobs && ret=0
|
||||
[[ "$tags" = *:process:* ]] && _pids && ret=0
|
||||
(( ret )) || break
|
||||
done
|
||||
|
||||
|
|
|
|||
18
Completion/Builtins/_pids
Normal file
18
Completion/Builtins/_pids
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
#autoload
|
||||
|
||||
# If given the `-m <pattern>' option, this tries to complete only pids
|
||||
# of processes whose command line match the `<pattern>'.
|
||||
|
||||
local list expl match
|
||||
|
||||
if [[ "$1" = -m ]]; then
|
||||
match="${2}*"
|
||||
shift 2
|
||||
fi
|
||||
|
||||
_description expl 'process ID'
|
||||
|
||||
list=("${(@Mr:COLUMNS-1:)${(f@)$(ps ${=compconfig[ps_listargs]:-$=compconfig[ps_args]} 2>/dev/null)}[2,-1]:#[ ]#${PREFIX}[0-9]#${SUFFIX}[ ]*${~match}}")
|
||||
|
||||
compadd "$expl[@]" "$@" -ld list - \
|
||||
${${${(M)${(f)"$(ps $=compconfig[ps_args] 2>/dev/null)"}[2,-1]:#*${~match}}## #}%% *}
|
||||
|
|
@ -1,18 +1,12 @@
|
|||
#compdef wait
|
||||
|
||||
local tags list ret=1 expl
|
||||
local tags ret=1
|
||||
|
||||
_tags job process
|
||||
|
||||
while _tags; do
|
||||
[[ "$tags" = *:job:* ]] && _jobs && ret=0
|
||||
if [[ "$tags" = *:process:* ]]; then
|
||||
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
|
||||
fi
|
||||
[[ "$tags" = *:job:* ]] && _jobs && ret=0
|
||||
[[ "$tags" = *:process:* ]] && _pids && ret=0
|
||||
(( ret )) || break
|
||||
done
|
||||
|
||||
|
|
|
|||
|
|
@ -2,13 +2,14 @@
|
|||
|
||||
if (( $# )); then
|
||||
local cmd="$words[1]" func="$funcstack[2]" defs i tags tag pat style prio
|
||||
local trynow
|
||||
|
||||
while getopts 'c:f:' i; do
|
||||
if [[ "$i" = c ]]; then
|
||||
cmd="$OPTARG"
|
||||
else
|
||||
func="$OPTARG"
|
||||
fi
|
||||
while getopts 'c:f:i' i; do
|
||||
case "$i" in
|
||||
c) cmd="$OPTARG" ;;
|
||||
f) func="$OPTARG" ;;
|
||||
i) trynow=yes ;;
|
||||
esac
|
||||
done
|
||||
|
||||
shift OPTIND-1
|
||||
|
|
@ -67,7 +68,7 @@ if (( $# )); then
|
|||
_prio_names[$funcstack]="$prio"
|
||||
eval "${prio}=( \"\${(@)tags:#}\" )"
|
||||
|
||||
return 0
|
||||
[[ -z "$trynow" ]] && return 0
|
||||
fi
|
||||
|
||||
local prios="$_prio_names[$funcstack]"
|
||||
|
|
|
|||
|
|
@ -21,20 +21,22 @@ elif [[ "$PREFIX" = -* ]]; then
|
|||
_description expl option
|
||||
compadd "$expl[@]" -QS '' - -symbols\= -exec\= -se\= -core\= -command\= \
|
||||
-directory\= -cd\= -tty\=
|
||||
compadd "$expl[@]" - -help -h -s -e -c -x -d -nx -n -quiet -q -batch \
|
||||
-fullname -f -b
|
||||
compadd "$expl[@]" - -help -h -s -e -c -x -d -nx -n -quiet -q \
|
||||
-batch -fullname -f -b
|
||||
else
|
||||
prev="$words[CURRENT-1]"
|
||||
|
||||
case "$prev" in
|
||||
(-d) _files -/ && return 0 ;;
|
||||
(-d) _files -/ && return 0 ;;
|
||||
(-[csx]) _files && return 0 ;;
|
||||
(-e) _description expl executable
|
||||
_files "$expl[@]" -g '*(*)' && return 0 ;;
|
||||
(-b) _description -V expl 'baud rate'
|
||||
compadd "$expl[@]" 0 50 75 110 134 150 200 300 600 1200 1800 2400 4800 \
|
||||
9600 19200 38400 57600 115200 230400 && return 0 ;;
|
||||
(-e) _description expl executable
|
||||
_files "$expl[@]" -g '*(*)' && return 0 ;;
|
||||
(-b) _description -V expl 'baud rate'
|
||||
compadd "$expl[@]" 0 50 75 110 134 150 200 300 600 1200 1800 \
|
||||
2400 4800 9600 19200 38400 57600 115200 \
|
||||
230400 && return 0 ;;
|
||||
esac
|
||||
|
||||
w=( "${(@)words[2,-1]}" )
|
||||
while [[ "$w[1]" = -* ]]; do
|
||||
[[ "$w[1]" = -[decsxb] ]] && shift 1 w
|
||||
|
|
@ -42,10 +44,8 @@ else
|
|||
done
|
||||
|
||||
if [[ $#w -gt 1 ]]; then
|
||||
_files && ret=0
|
||||
_description expl 'process ID'
|
||||
list=("${(@M)${(f)$(ps ${=compconfig[ps_listargs]:-$=compconfig[ps_args]} 2>/dev/null)}[2,-1]:#[ ]#${PREFIX}[0-9]#${SUFFIX}[ ]*${w[1]:t}*}")
|
||||
compadd "$expl[@]" -ld list - ${${${(M)${(f)"$(ps $=compconfig[ps_args] 2>/dev/null)"}:#*${w[1]:t}*}## #}%% *} && ret=0
|
||||
_files && ret=0
|
||||
_pids -m "${w[1]:t}" && ret=0
|
||||
|
||||
return ret
|
||||
else
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue