From 9888b262c2deb32064b30eb637ece9e424356777 Mon Sep 17 00:00:00 2001 From: Sebastien Luttringer Date: Thu, 5 May 2011 01:26:44 +0200 Subject: Add syntax to vim modeline in rc.d script With new name of script, vim doesn't reconize correctly file format. We need to set it explicitly. Signed-off-by: Sebastien Luttringer --- rc.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rc.d b/rc.d index 02c2b6c..49b7c2f 100755 --- a/rc.d +++ b/rc.d @@ -58,4 +58,4 @@ esac exit $ret -# vim: set ts=2 sw=2 noet: +# vim: set ts=2 sw=2 ft=sh noet: -- cgit v1.2.3 From d1be877eb0ad3be634cee08aada8f8d1265023a4 Mon Sep 17 00:00:00 2001 From: Sebastien Luttringer Date: Thu, 5 May 2011 01:42:07 +0200 Subject: Add TERM var to rc.d cleaned env We need to do this to allow a correct detection of terminal colors in functions sourced by rc.d scripts Signed-off-by: Sebastien Luttringer --- rc.d | 1 + 1 file changed, 1 insertion(+) diff --git a/rc.d b/rc.d index 49b7c2f..55871b1 100755 --- a/rc.d +++ b/rc.d @@ -50,6 +50,7 @@ case $1 in ENV+=" PREVLEVEL='${runlevel:0:1}'" ENV+=" RUNLEVEL='${runlevel:2:1}'" ENV+=" CONSOLE='${CONSOLE:-/dev/console}'" + ENV+=" TERM='${TERM}'" for i; do [[ -x "/etc/rc.d/$i" ]] && cd / && eval /usr/bin/env -i $ENV "/etc/rc.d/$i" "$action" (( ret += !! $? )) # clamp exit value to 0/1 -- cgit v1.2.3 From 1ba11e7f78af5742dbc211d9202db4549558ca44 Mon Sep 17 00:00:00 2001 From: Sebastien Luttringer Date: Wed, 4 May 2011 23:35:25 +0200 Subject: Improve coloring on light and transparent term This patch improve coloring in light and transparent term. It uses tput if available or default color code. It remplace \033 by \e. It's a kind of rollback from commit 65f410, because initscripts are now in bash, and argument "\e isn't recongized in all shells" is not an issue anymore. This is not done in locale.sh script which can be sourced by others shell, so we try to be the more compliant as possible Signed-off-by: Sebastien Luttringer --- functions | 47 ++++++++++++++++++++++++++++------------------- rc.sysinit | 4 ++-- 2 files changed, 30 insertions(+), 21 deletions(-) diff --git a/functions b/functions index 6d279cc..27e53d0 100644 --- a/functions +++ b/functions @@ -49,28 +49,37 @@ else export LANG=C fi -# colors: -if [[ $USECOLOR = YES || $USECOLOR = yes ]]; then - C_MAIN="\033[1;37;40m" # main text - - C_OTHER="\033[1;34;40m" # prefix & brackets - C_SEPARATOR="\033[1;30;40m" # separator - - C_BUSY="\033[0;36;40m" # busy - C_FAIL="\033[1;31;40m" # failed - C_DONE="\033[1;37;40m" # completed - C_BKGD="\033[1;35;40m" # backgrounded - - C_H1="\033[1;37;40m" # highlight text 1 - C_H2="\033[1;36;40m" # highlight text 2 - - C_CLEAR="\033[1;0m" +# set colors +if [[ $USECOLOR =~ yes|YES ]]; then + if /bin/tput setaf 0 &>/dev/null; then + C_CLEAR="$(tput sgr0)" # clear text + C_MAIN="${C_CLEAR}$(/bin/tput bold)" # main text + C_OTHER="${C_MAIN}$(/bin/tput setaf 4)" # prefix & brackets + C_SEPARATOR="${C_MAIN}$(/bin/tput setaf 0)" # separator + C_BUSY="${C_CLEAR}$(/bin/tput setaf 6)" # busy + C_FAIL="${C_MAIN}$(/bin/tput setaf 1)" # failed + C_DONE="${C_MAIN}" # completed + C_BKGD="${C_MAIN}$(/bin/tput setaf 5)" # backgrounded + C_H1="${C_MAIN}" # highlight text 1 + C_H2="${C_MAIN}$(/bin/tput setaf 6)" # highlight text 2 + else + C_CLEAR="\e[m" # clear text + C_MAIN="\e[;1m" # main text + C_OTHER="\e[1;34m" # prefix & brackets + C_SEPARATOR="\e[1;30m" # separator + C_BUSY="\e[;36m" # busy + C_FAIL="\e[1;31m" # failed + C_DONE="${C_MAIN}" # completed + C_BKGD="\e[1;35m" # backgrounded + C_H1="${$C_MAIN}" # highlight text 1 + C_H2="\e[1;36m" # highlight text 2 + fi fi if [[ -t 1 ]]; then - SAVE_POSITION="\033[s" - RESTORE_POSITION="\033[u" - DEL_TEXT="\033[$(($STAT_COL+4))G" + SAVE_POSITION="\e[s" + RESTORE_POSITION="\e[u" + DEL_TEXT="\e[$(($STAT_COL+4))G" else SAVE_POSITION="" RESTORE_POSITION="" diff --git a/rc.sysinit b/rc.sysinit index fa1ba5f..e5ed095 100755 --- a/rc.sysinit +++ b/rc.sysinit @@ -356,7 +356,7 @@ if [[ ${LOCALE,,} =~ utf ]]; then # but also when user has set vt.default_utf8=0 but LOCALE is *.UTF-8. for i in /dev/tty[0-9]*; do /usr/bin/kbd_mode -u < ${i} - printf "\033%%G" > ${i} + printf "\e%%G" > ${i} done echo 1 > /sys/module/vt/parameters/default_utf8 stat_done @@ -366,7 +366,7 @@ else # make non-UTF-8 consoles work on 2.6.24 and newer kernels for i in /dev/tty[0-9]*; do /usr/bin/kbd_mode -a < ${i} - printf "\033%%@" > ${i} + printf "\e%%@" > ${i} done echo 0 > /sys/module/vt/parameters/default_utf8 stat_done -- cgit v1.2.3 From d4d9f1f97f0fbf798eafbb5c1c1976c342605eb5 Mon Sep 17 00:00:00 2001 From: Sebastien Luttringer Date: Thu, 5 May 2011 02:50:11 +0200 Subject: Add rc.d bash completion Signed-off-by: Sebastien Luttringer --- Makefile | 3 ++- bash-completion | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 bash-completion 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 + +_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: -- cgit v1.2.3 From d543c7aa098c214fa5e55a497353dda47b95d3ad Mon Sep 17 00:00:00 2001 From: Sebastien Luttringer Date: Sat, 21 May 2011 21:12:28 +0200 Subject: rc.d bash completion detect running daemon This patch adds sexy features from Auguste Pop bash completion patch. Mainly, detect if a daemon is running and complete accordingly Signed-off-by: Sebastien Luttringer --- bash-completion | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bash-completion b/bash-completion index 3b0f464..5151972 100644 --- a/bash-completion +++ b/bash-completion @@ -7,10 +7,14 @@ _rc.d () local caction="${COMP_WORDS[1]}" if ((${COMP_CWORD} == 1)); then COMPREPLY=($(compgen -W "${action}" -- "$cur")) - elif [[ "$caction" == "help" || "$caction" == "list" ]]; then + 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=($( compgen -W "$(find /etc/rc.d -maxdepth 1 -type f -executable -printf '%f\n')" -- "$cur" )) + COMPREPLY=($(cd /etc/rc.d && compgen -f -X 'functions*' "$cur"|sort)) fi } complete -F _rc.d rc.d -- cgit v1.2.3 From 395803ff628e41940bbaaf5f1ffbcf591b007102 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20D=C3=A9moulins?= Date: Wed, 18 May 2011 22:16:02 +0200 Subject: Add a zsh completion script for the command rc.d. seblu: Fix typo, add vim modeline Signed-off-by: Sebastien Luttringer --- Makefile | 3 ++- zsh-completion | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 zsh-completion diff --git a/Makefile b/Makefile index 25c9b58..968cfb9 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 /etc/bash_completion.d +DIRS := /etc/rc.d /etc/conf.d /etc/rc.d/functions.d /etc/cron.hourly /sbin /etc/modprobe.d /etc/bash_completion.d /usr/share/zsh/site-functions minilogd: minilogd.o @@ -15,6 +15,7 @@ install: minilogd installdirs 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 + install -m644 -T zsh-completion $(DESTDIR)/usr/share/zsh/site-functions/_rc.d clean: rm -f minilogd minilogd.o diff --git a/zsh-completion b/zsh-completion new file mode 100644 index 0000000..bf8d9d0 --- /dev/null +++ b/zsh-completion @@ -0,0 +1,34 @@ +#compdef rc.d + +_rc.d () { + local curcontext="$curcontext" state line + typeset -A opt_args + + _arguments "1: :->action" "*: :->service" + + case $state in + action) + _arguments "1:action:(list help start stop restart)" + ;; + service) + local action="$words[2]" + curcontext="${curcontext%:*:*}:rc.d-${action}:" + + case $action in + list) + _arguments "*: :" + ;; + help) + _arguments "*: :" + ;; + *) + _arguments "*: :_services" + ;; + esac + ;; + esac +} + +_rc.d "$@" + +# vim: set ts=2 sw=2 ft=sh noet: -- cgit v1.2.3 From 18adeacb36967463330060237725ffbdfd47e2a7 Mon Sep 17 00:00:00 2001 From: Sebastien Luttringer Date: Mon, 23 May 2011 01:13:57 +0200 Subject: rc.d zsh completion detect running daemons This patch adds functionalities of bash completions about running demons Signed-off-by: Sebastien Luttringer --- zsh-completion | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/zsh-completion b/zsh-completion index bf8d9d0..f1b7165 100644 --- a/zsh-completion +++ b/zsh-completion @@ -15,14 +15,17 @@ _rc.d () { curcontext="${curcontext%:*:*}:rc.d-${action}:" case $action in - list) + list|help) _arguments "*: :" ;; - 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 "*: :_services" + _arguments "*: :(/etc/rc.d/*(N-*:t))" ;; esac ;; -- cgit v1.2.3