aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastien Luttringer <seblu@seblu.net>2011-05-05 00:50:11 (GMT)
committerSebastien Luttringer <seblu@seblu.net>2011-05-21 22:24:45 (GMT)
commitd4d9f1f97f0fbf798eafbb5c1c1976c342605eb5 (patch)
treec4e581a7cc55d05c3a4512b9f2183398511012af
parent1ba11e7f78af5742dbc211d9202db4549558ca44 (diff)
downloadinitscripts-d4d9f1f97f0fbf798eafbb5c1c1976c342605eb5.tar.xz
Add rc.d bash completion
Signed-off-by: Sebastien Luttringer <seblu@seblu.net>
-rw-r--r--Makefile3
-rw-r--r--bash-completion18
2 files changed, 20 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index ad8a058..25c9b58 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
VER := $(shell git describe)
-DIRS := /etc/rc.d /etc/conf.d /etc/rc.d/functions.d /etc/cron.hourly /sbin /etc/modprobe.d
+DIRS := /etc/rc.d /etc/conf.d /etc/rc.d/functions.d /etc/cron.hourly /sbin /etc/modprobe.d /etc/bash_completion.d
minilogd: minilogd.o
@@ -14,6 +14,7 @@ install: minilogd installdirs
install -m755 -t $(DESTDIR)/etc/rc.d hwclock network netfs
install -m755 -t $(DESTDIR)/sbin minilogd rc.d modprobe-blacklist
ln -s /run/initscripts/modprobe-blacklist.conf $(DESTDIR)/etc/modprobe.d/arch-blacklist.conf
+ install -m644 -T bash-completion $(DESTDIR)/etc/bash_completion.d/rc.d
clean:
rm -f minilogd minilogd.o
diff --git a/bash-completion b/bash-completion
new file mode 100644
index 0000000..3b0f464
--- /dev/null
+++ b/bash-completion
@@ -0,0 +1,18 @@
+# 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" || "$caction" == "list" ]]; then
+ COMPREPLY=()
+ elif ((${COMP_CWORD} > 1)); then
+ COMPREPLY=($( compgen -W "$(find /etc/rc.d -maxdepth 1 -type f -executable -printf '%f\n')" -- "$cur" ))
+ fi
+}
+complete -F _rc.d rc.d
+
+# vim: set ts=2 sw=2 ft=sh noet: