bash_completion

Marcin Sztolcman lists at urzenia.net
Wed Aug 25 12:41:34 CEST 2004


Witam
Czy warto wysylac tutaj (w sensie : czy beda dodawane gdzies do pakietu) 
pliczki z bash_completion ? Niektore mi osobiscie sie bardzo przydaja, i 
milo by bylo gdybym nie musial sam sobie je przesylac miedzy 
komputerami, tylko pojawialyby sie 'automagicznie' przy upgrade'zie systemu.
Jesli ktos jest zainteresowany, to przesylam dwa w zalaczniku, te 
ktorych brak najbardziej mnie denerwuje przy grzebaniu w ktoryms 
komputerze/serwerze...

	MySZ
-- 
[     Marcin ``MySZ`` Sztolcman     ]
[ marcin { at } urzenia { dot } net ]
[        http://mysz.ath.cx         ]
-------------- next part --------------
# chkconfig(1) completion by Marcin Sztolcman <marcin at urzenia.net>
#
# $Id: $

_chkconfig() 
{
	local cur

	COMPREPLY=()
	cur=${COMP_WORDS[COMP_CWORD]}
	
	all_services=''
	dir='/etc/rc.d/init.d/'
	for service in ${dir}*; do
		if [ ! "$service" == 'functions' ]; then
			all_services="${service:${#dir}} $all_services";
		fi
	done
	
	active_services=`chkconfig --list`
	active_services="`echo $active_services | sed 's/[0-7]:\w*//g' | tr -s ' '`"

	

	if [ $COMP_CWORD -eq 1 ]; then
		COMPREPLY=( $( compgen -W '--add --del --level --list --init.d --rc.d --xinetd.d' -- $cur) )
	elif [ $COMP_CWORD -eq 2 ]; then
		case "${COMP_WORDS[1]}" in
			--list|--del)
				COMPREPLY=( $( compgen -W "$active_services" -- $cur) )
				;;
			--add)
				COMPREPLY=( $( compgen -W "$all_services" -- $cur) )
				;;
			--level)
				COMPREPLY=( $( compgen -W '0 1 2 3 4 5 6 7' -- $cur) )
				;;
			--init.d|--rc.d|--xinetd.d)
				_filedir @
				;;
		esac
	elif [ $COMP_CWORD -eq 3 -a ${COMP_WORDS[1]} == '--level' ]; then
		COMPREPLY=( $( compgen -W "$active_services" -- $cur) )
	elif [ $COMP_CWORD -eq 4 ]; then
		COMPREPLY=( $( compgen -W "on off reset" -- $cur) )
	else
		_filedir '@'
	fi
  
	return 0

}

complete -F _chkconfig -o default chkconfig

-------------- next part --------------
# service(1) completion by Marcin Sztolcman <marcin at urzenia.net>
#
# $Id: $

_service() 
{
	local cur

	COMPREPLY=()
	cur=${COMP_WORDS[COMP_CWORD]}
	services=''
	dir='/etc/rc.d/init.d/'
	for service in ${dir}*; do
		if [ ! "$service" == 'functions' ]; then
			services="${service:${#dir}} $services";
		fi
	done
	#parms="debug dump force-reload graceful init probe reload restart restore start status stop"
	parms="start stop restart status reload force-reload debug dump init graceful probe restore"

	if [ $COMP_CWORD -eq 1 ]; then
		COMPREPLY=( $( compgen -W "$services" -- $cur ) )
	elif [ $COMP_CWORD -eq 2 ]; then
		COMPREPLY=( $( compgen -W "$parms" -- $cur) )
	else
		_filedir '@'
	fi
  
	return 0

}

complete -F _service -o default service



More information about the pld-devel-pl mailing list