[*] First commit
This commit is contained in:
24
completions/bash-completion
Normal file
24
completions/bash-completion
Normal file
@@ -0,0 +1,24 @@
|
||||
# rc.d bash completion by Seblu <seblu@seblu.net>
|
||||
|
||||
_rc_d()
|
||||
{
|
||||
local action cur prev
|
||||
actions='help list start stop reload restart'
|
||||
options='-s --started -S --stopped -a --auto -A --noauto'
|
||||
_get_comp_words_by_ref cur prev
|
||||
_get_first_arg
|
||||
if [[ -z "$arg" ]]; then
|
||||
COMPREPLY=($(compgen -W "${actions} ${options}" -- "$cur"))
|
||||
elif [[ "$arg" == help ]]; then
|
||||
COMPREPLY=()
|
||||
elif [[ "$arg" == start ]]; then
|
||||
COMPREPLY=($(comm -23 <(cd /etc/rc.d && compgen -f -X 'functions*' "$cur"|sort) <(cd /run/daemons/ && compgen -f "$cur"|sort)))
|
||||
elif [[ "$arg" =~ stop|restart|reload ]]; then
|
||||
COMPREPLY=($(cd /run/daemons/ && compgen -f "$cur"|sort))
|
||||
else
|
||||
COMPREPLY=($(compgen -W "${options} $(cd /etc/rc.d && compgen -f -X 'functions*')" -- "$cur"))
|
||||
fi
|
||||
}
|
||||
complete -F _rc_d rc.d
|
||||
|
||||
# vim: set ts=2 sw=2 ft=sh noet:
|
36
completions/zsh-completion
Normal file
36
completions/zsh-completion
Normal file
@@ -0,0 +1,36 @@
|
||||
#compdef rc.d
|
||||
|
||||
_rc.d () {
|
||||
local curcontext="$curcontext" state line
|
||||
typeset -A opt_args
|
||||
|
||||
_arguments "1: :->action" "*: :->service" {-s,--started} {-S,--stopped} {-a,--auto} {-A,--noauto}
|
||||
case $state in
|
||||
action)
|
||||
_arguments "*:action:(list help start stop restart)"
|
||||
;;
|
||||
service)
|
||||
local action="$words[2]"
|
||||
curcontext="${curcontext%:*:*}:rc.d-${action}:"
|
||||
|
||||
case $action in
|
||||
help)
|
||||
_arguments "*: :"
|
||||
;;
|
||||
start)
|
||||
_arguments "*: :($(comm -23 <(echo /etc/rc.d/*(N-*:t)|tr ' ' '\n') <(echo /run/daemons/*(N:t)|tr ' ' '\n')))"
|
||||
;;
|
||||
stop|restart|reload)
|
||||
_arguments "*: :(/run/daemons/*(N:t))"
|
||||
;;
|
||||
*)
|
||||
_arguments "*: :(/etc/rc.d/*(N-*:t))"
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
_rc.d "$@"
|
||||
|
||||
# vim: set ts=2 sw=2 ft=sh noet:
|
Reference in New Issue
Block a user