How to set Auto Complete “service” command on Redhat

Posted by Planet Malaysia on January 19, 2009

advertisement

I have been using SuSE Linux for some time and I love SuSE Linux service script that activated with a symbolic link. In order to start a SSH service, I can easily issue a command “rcsshd start”.

For Redhat or Centos Linux, you’re require to type command such as “service sshd start” and the main problem is NO auto complete for service command by default. Yes I admitted I’m lazy guy!

So how to set AUTO COMPLETE “service” command on Redhat/Centos?

Type:
complete -W "$(ls /etc/init.d/)" service

* complete : the command complete sets up tab completion
* -W : this option creates a word list for completion
* “$(ls /etc/init.d/)” : out word list is made up of the output of the command ls /etc/init.d/
* service : this then sets up the configured completion for the command service

So when you issue a command “service n” and press tab, you should be able to see any services that start with the word “n” within /etc/init.d/ folder such as “ntpd”, “network”, “nfs” and etc.

Enjoy!

Possibly Related Posts:


Comments

Leave a Reply




Planet Malaysia

  • Follow us on Twitter


  • web www.planetmy.com