1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-01-01 17:24:50 +01:00

add exclusion lists and use _multi_parts for sysctl completion on BSD (15252)

This commit is contained in:
Oliver Kiddle 2001-07-06 11:28:32 +00:00
parent c9de3db973
commit 871dd54d31
3 changed files with 69 additions and 17 deletions

View file

@ -1,3 +1,9 @@
2001-07-06 Oliver Kiddle <opk@zsh.org>
* 15252 (and Akinori Musha: 15245): Completion/BSD/Command/_kld,
Completion/Unix/Command/_sysctl: Add exclusion lists and use
_multi_parts for BSD completion of sysctl.
2001-07-06 Sven Wischnowsky <wischnow@zsh.org>
* 15283: Completion/Unix/Type/_path_files: when looking for

View file

@ -0,0 +1,43 @@
#compdef kldload kldunload
(( $+functions[_kld_module] )) ||
_kld_module() {
local ret=1
compadd "$@" - /boot/kernel/*.ko(:t) /modules/*.ko(:t) && ret=0
_files "$@" -g \*.ko && ret=0
return ret
}
(( $+functions[_kld_unload] )) ||
_kld_unload() {
compadd "$@" - $( /sbin/kldstat | awk '($1 ~ /^[0-9]/) { print $5 }' )
}
(( $+functions[_kld_unload_id] )) ||
_kld_unload_id() {
compadd "$@" - $( /sbin/kldstat | awk '($1 ~ /^[0-9]/) { print $1 }' )
}
_kld() {
unset _cache_sysctlvars
case "$service" in
kldload)
_arguments -s \
'-v[be verbose]' \
'*:module to load:_kld_module'
;;
kldunload)
_arguments -s \
'-v[be verbose]' \
'(-n)-i:module id to unload:_kld_unload_id' \
'(-i)-n:module to unload:_kld_unload' \
'*:module to unload:_kld_unload'
;;
esac
}
_kld "$@"

View file

@ -1,25 +1,28 @@
#compdef sysctl
case $OSTYPE in
freebsd[0-4]*)
_arguments -s \
'-a[list all]' \
'-A[show all opaques (values suppressed)]' \
'-b[binary output]' \
'-n[show only variable values]' \
'-w[write mode]' \
'-X[show all opaques (entire values)]' \
"*:sysctl variable:compadd ${words[(r)-w]:+-S =} $(sysctl -A | sed 's/:.*//')"
freebsd[0-4].*)
: ${(A)_cache_sysctlvars:=${${$(sysctl -A):#[^a-z]*}%%:*}}
_arguments -s -A "-*" \
'(-w -X *)-a[list all]' \
'(-w -X *)-A[show all opaques (values suppressed)]' \
'(-w)-b[binary output]' \
'(-w)-n[show only variable values]' \
'(-a -A -b -n -X)-w[write mode]' \
'(-a -A -w *)-X[show all opaques (entire values)]' \
'(-a -A -X)*:sysctl variable:_multi_parts ${words[(r)-w]:+-S=} -i . _cache_sysctlvars'
;;
freebsd[5-9]*)
_arguments -s \
'-a[list all]' \
freebsd[5-9].*)
local -a sysctlvars
sysctlvars=( $(sysctl -aN) )
_arguments -s -A "-*" \
'(*)-a[list all]' \
'-b[binary output]' \
'-N[show only variable names]' \
'-n[show only variable values]' \
'-o[show opaques as well (values suppressed)]' \
'-x[show opaques as well (entire values)]' \
'*:sysctl variable:compadd -S "" - $(sysctl -aN)'
'(-n)-N[show only variable names]' \
'(-N)-n[show only variable values]' \
'(-x)-o[show opaques as well (values suppressed)]' \
'(-o)-x[show opaques as well (entire values)]' \
'(-a)*:sysctl variable:_multi_parts -i . sysctlvars'
;;
linux*)
_arguments -A "-*" \