diff options
author | Tom Gundersen <teg@jklm.no> | 2011-05-23 01:31:48 +0200 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2011-05-23 01:31:48 +0200 |
commit | dfdf8b683633d89a9c7c7560397c57a8a1594147 (patch) | |
tree | dca5033418b54a29dd3722cb2a119e852bd700ad /bash-completion | |
parent | a3314c769768d8c40b46767d26f9783d4f359358 (diff) | |
parent | 18adeacb36967463330060237725ffbdfd47e2a7 (diff) | |
download | initscripts-dfdf8b683633d89a9c7c7560397c57a8a1594147.tar.xz |
Merge remote-tracking branch 'seblu/master'
Diffstat (limited to 'bash-completion')
-rw-r--r-- | bash-completion | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/bash-completion b/bash-completion new file mode 100644 index 0000000..5151972 --- /dev/null +++ b/bash-completion @@ -0,0 +1,22 @@ +# rc.d bash completion by Seblu <seblu@seblu.net> + +_rc.d () +{ + local action="help list start stop reload restart" + local cur="${COMP_WORDS[COMP_CWORD]}" + local caction="${COMP_WORDS[1]}" + if ((${COMP_CWORD} == 1)); then + COMPREPLY=($(compgen -W "${action}" -- "$cur")) + elif [[ "$caction" =~ help|list ]]; then + COMPREPLY=() + elif [[ "$caction" == start ]]; then + COMPREPLY=($(comm -23 <(cd /etc/rc.d && compgen -f -X 'functions*' "$cur"|sort) <(cd /run/daemons/ && compgen -f "$cur"|sort))) + elif [[ "$caction" =~ stop|restart|reload ]]; then + COMPREPLY=($(cd /run/daemons/ && compgen -f "$cur"|sort)) + elif ((${COMP_CWORD} > 1)); then + COMPREPLY=($(cd /etc/rc.d && compgen -f -X 'functions*' "$cur"|sort)) + fi +} +complete -F _rc.d rc.d + +# vim: set ts=2 sw=2 ft=sh noet: |