diff --git a/Makefile b/Makefile index 663e103e..d49bef9c 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ MK= ${TOP}/mk include ${TOP}/Makefile.inc SUBDIR= bash-completion conf.d etc init.d local.d man scripts sh src \ - support sysctl.d + support sysctl.d zsh-completion # Build pkgconfig or not MKPKGCONFIG?= yes diff --git a/mk/sys.mk b/mk/sys.mk index 82373dfe..db3fb779 100644 --- a/mk/sys.mk +++ b/mk/sys.mk @@ -34,6 +34,7 @@ PICFLAG?= -fPIC SYSCONFDIR?= ${PREFIX}/etc INITDIR?= ${SYSCONFDIR}/init.d CONFDIR?= ${SYSCONFDIR}/conf.d +CONFMODE?= 0644 LOCALDIR?= ${SYSCONFDIR}/local.d SYSCTLDIR?= ${SYSCONFDIR}/sysctl.d @@ -67,4 +68,4 @@ DATAMODE?= 0644 DOCDIR?= ${UPREFIX}/share/doc DOCMODE?= 0644 -CONFMODE?= 0644 +ZSHCOMPDIR?= ${UPREFIX}/share/zsh/site-functions diff --git a/zsh-completion/Makefile b/zsh-completion/Makefile new file mode 100644 index 00000000..9654dbb4 --- /dev/null +++ b/zsh-completion/Makefile @@ -0,0 +1,10 @@ +DIR= ${ZSHCOMPDIR} +CONF= _openrc \ + _rc-service \ + _rc-status \ + _rc-update \ + +MK= ../mk +include ${MK}/os.mk + +include ${MK}/scripts.mk diff --git a/zsh-completion/_openrc b/zsh-completion/_openrc new file mode 100644 index 00000000..3336b44b --- /dev/null +++ b/zsh-completion/_openrc @@ -0,0 +1,7 @@ +#compdef openrc + +if (( CURRENT == 2 )); then + _values "runlevels" $(rc-status --list) +fi + +# vim: set et sw=2 ts=2 ft=zsh: diff --git a/zsh-completion/_rc-service b/zsh-completion/_rc-service new file mode 100644 index 00000000..25c6b4c5 --- /dev/null +++ b/zsh-completion/_rc-service @@ -0,0 +1,27 @@ +#compdef rc-service + +if (( CURRENT == 2 )); then + _arguments -s \ + '(-e --exists)'{-e,--exists}"[tests if the service exists or not]" \ + '(-l --list)'{-l,--list}'[list all available services]' \ + '(-r --resolve)'{-r,--resolve}'[resolve the service name to an init script]' \ + '(-C --nocolor)'{-C,--nocolor}'[Disable color output]' \ + '(-v --verbose)'{-v,--verbose}'[Run verbosely]' \ + '(-q --quiet)'{-q,--quiet}'[Run quietly]' + _values "service" $(rc-service --list) +else + case $words[2] in + -e|--exists|-r|--resolve) + (( CURRENT > 3 )) && return 0 + _values "service" $(rc-service --list) + ;; + -*) + return 0 + ;; + *) + _values "action" stop start restart describe zap + ;; + esac +fi + +# vim: set et sw=2 ts=2 ft=zsh: diff --git a/zsh-completion/_rc-status b/zsh-completion/_rc-status new file mode 100644 index 00000000..fd35e9cd --- /dev/null +++ b/zsh-completion/_rc-status @@ -0,0 +1,18 @@ +#compdef rc-status + +_arguments -s \ + {'(--all)-a','(-a)--all'}'[Show services at all runlevels]' \ + {'(--crashed)-c','(-c)--crashed'}'[Show crashed services]' \ + {'(--list)-l','(-l)--list'}'[Show list of runlevels]' \ + {'(--runlevel)-r','(-r)--runlevel'}'[Show the name of the current runlevel]' \ + {'(--servicelist)-s','(-s)--servicelist'}'[Show all services]' \ + {'(--unused)-u','(-u)--unused'}'[Show services not assigned to any run level]' \ + {'(--help)-h','(-h)--help'}'[Print this help output]' \ + {'(--nocolor)-C','(-C)--nocolor'}'[Disable color output]' \ + {'(--version)-V','(-V)--version'}'[Display software version]' \ + {'(--verbose)-v','(-v)--verbose'}'[Run verbosely]' \ + {'(--quiet)-q','(-q)--quiet'}'[Run quietly (Does not affect errors)]' + +_values 'runlevels' $(rc-status --list) + +# vim: set et sw=2 ts=2 ft=zsh: diff --git a/zsh-completion/_rc-update b/zsh-completion/_rc-update new file mode 100644 index 00000000..5bd3c85c --- /dev/null +++ b/zsh-completion/_rc-update @@ -0,0 +1,31 @@ +#compdef rc-update + +local used_init +used_init=(${=${(M)${(f)"$(rc-update show 2>/dev/null)"}:#*|*[a-z]*}% |*}) + +if (( CURRENT == 2 )); then + _values "rc-update actions" \ + 'add[Add script to a runlevel]' \ + 'del[Delete script from a runlevel]' \ + 'show[Show scripts in a runlevel]' \ + '-a[Process all runlevels]' \ + '-s[Stack a runlevel instead of a service]' +elif (( CURRENT == 3 )); then + case "$words[2]" in + add) + _values "service" $(rc-service --list) + ;; + del) + _values "service" $used_init + ;; + show) + _values "runlevels" $(rc-status --list) \ + '-v[Show all service scripts]' \ + '--verbose[Show all service scripts]' + ;; + esac +elif (( CURRENT == 4 )); then + _values "runlevels" $(rc-status --list) +fi + +# vim: set et sw=2 ts=2 ft=zsh: