[Tipz] useful zsh completions for Redhat systems

Jon Hart jhart at ccs.neu.edu
Tue Apr 1 18:33:23 EST 2003


If you find yourself administering a Redhat box, you may be familiar with
the 'service' and 'chkconfig' commands which make service and runlevel
service manipulation a breeze.

To dumb it down even more, if you use zsh, you can use the following
completion rules to tab complete things:

# a list of the services
rh_services=(`ls /etc/init.d`)
# rip out the current runlevel
runlevel=`runlevel | awk '{print $2}'`
# find all the services in the current runlevel
rl_services=(`ls /etc/rc$runlevel.d/S* | xargs -n 1 basename | perl -ne
's/^S\d+//; print'`)

compctl -k "($rh_services)" chkconfig 
compctl -k "($rl_services)" service

Its not perfect, but I've been using it for many months and haven't had any
issues.

Examples:

$  chkconfig --level 2345 s<tab>
saslauthd      smb            snmptrapd      spamassassin   syslog
single         snmpd          snortd         sshd           


-jon



More information about the Tipz mailing list