Hello,
here is bash completion script for all users of Bash and initng...
Initng is cool!
Have a nice day, Michal Heppler
--
Leží-li ti na srdci blaho tvých dětí, nech je zakusit trochu zimy a hladu.
-- přísloví
# initNG completion
# Copyright 2006 Michal Heppler <[EMAIL PROTECTED]>
# License: GNU GPL v2 or later
have ngc &&
_ngc()
{
local cur conns prev single with_opt may_opt
[ -r /etc/initng/ ] || return 0
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
prev=${COMP_WORDS[COMP_CWORD-1]}
services=$(find /etc/initng/*/ -type f -not -name "*~" -exec cat "{}"
\; | awk '/(^[[:blank:]]*daemon)|(^[[:blank:]]*service)|(^[[:blank:]]*virtual)/
{ ORS=" "; print $2}')
single='-h --help \
-H --help_all \
-c --hot_reload \
-s --status \
-6 --reboot \
-0 --halt \
-m --print_plugins \
-n --done \
-I --list_filedescriptors \
-v --verbose \
-y --stop_unneeded'
with_opt='-u --start \
-d --stop \
-g --get_pid_of \
-j --restart_from \
-r --restart \
-t --time \
-o --load_module \
-w --unload_module \
-f --father \
-a --service_dep_on \
-A --service_dep_on_deep \
-b --service_dep_on_me \
-B --service_dep_on_me_deep \
-e --runlevel \
-i --add_verbose \
-k --del_verbose \
-U --run'
may_opt='-z --zap \
-O --options \
-R --reload_service \
-p --print_service_db \
-P --print_active_db \
-L --show_history \
-l --log'
if [ "$prev" == "ngc" ]; then
COMPREPLY=( $( compgen -W "$single $with_opt $may_opt" -- $cur
) )
return 0;
fi
case "$prev" in
-h|--help| \
-H|--help_all| \
-c|--hot_reload| \
-s|--status| \
-6|--reboot| \
-0|--halt| \
-m|--print_plugins| \
-n|--done| \
-I|--list_filedescriptors| \
-v|--verbose| \
-y|--stop_unneeded)
return 0;
;;
-u|--start| \
-d|--stop| \
-g|--get_pid_of| \
-j|--restart_from| \
-r|--restart| \
-t|--time| \
-o|--load_module| \
-w|--unload_module| \
-f|--father| \
-a|--service_dep_on| \
-A|--service_dep_on_deep| \
-b|--service_dep_on_me| \
-B|--service_dep_on_me_deep| \
-e|--runlevel| \
-i|--add_verbose| \
-k|--del_verbose| \
-U|--run)
COMPREPLY=( $( compgen -W "$services" -- $cur ) )
return 0;
;;
-z|--zap| \
-O|--options| \
-R|--reload_service| \
-p|--print_service_db| \
-P|--print_active_db| \
-L|--show_history| \
-l|--log)
COMPREPLY=( $( compgen -W "$services $single $with_opt
$may_opt" -- $cur ) )
return 0;
;;
esac
COMPREPLY=( $( compgen -W "$services $single $with_opt $may_opt" --
$cur ) )
return 0
}
[ "$have" ] && complete -F _ngc ngc
have ng-update &&
_ng_update() {
local cur conns prev services
[ -r /etc/initng/ ] || return 0
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
prev=${COMP_WORDS[COMP_CWORD-1]}
services=$(find /etc/initng/*/ -type f -not -name "*~" -exec cat "{}"
\; | awk '/(^[[:blank:]]*daemon)|(^[[:blank:]]*service)|(^[[:blank:]]*virtual)/
{ ORS=" "; print $2}')
runlevels=$(find /etc/initng/ -name *.runlevel | sed -e
's|.*\/\([^/]*\)\.runlevel|\1|' )
if [ "$prev" == "ng-update" ]; then
COMPREPLY=( $( compgen -W "a d s -h" -- $cur ) )
return 0;
fi
case "$prev" in
a|d)
COMPREPLY=( $( compgen -W "$services" -- $cur ) )
return 0;
;;
s)
COMPREPLY=( $( compgen -W "$services $runlevels" --
$cur ) )
return 0;
;;
esac
if echo "$services" | grep -q "$prev"; then
COMPREPLY=( $( compgen -W "$services $runlevels" -- $cur ) )
elif echo "$runlevels" | grep -q "$prev"; then
COMPREPLY=( $( compgen -W "$runlevels" -- $cur ) )
fi
return 0;
}
[ "$have" ] && complete -F _ng_update ng-update
have ngstart &&
_ngstart() {
local cur conns services
[ -r /etc/initng/ ] || return 0
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
services=$(find /etc/initng/*/ -type f -not -name "*~" -exec cat "{}"
\; | awk '/(^[[:blank:]]*daemon)|(^[[:blank:]]*service)|(^[[:blank:]]*virtual)/
{ ORS=" "; print $2}')
COMPREPLY=( $( compgen -W "$services $runlevels" -- $cur ) )
return 0;
}
[ "$have" ] && complete -F _ngstart ngstart ngstop ngrestart
# vim:ft=sh:
--
_______________________________________________
Initng mailing list
[email protected]
http://jw.dyndns.org/mailman/listinfo/initng