3

I've made a startup script, (i.e. myserviced) and put it in /etc/init.d/

I ran

chkconfig --add myserviced

I can start/stop/restart the service just find using:

service myserviced start

etc. However, I notice that when I type "service" and then do TAB (to get a list of possible completions), I don't see myserviced in the list of possible completions (it lists all the other services). How do I add myserviced to the auto-completion list?

This is in zsh on RHEL.

Thanks

Switch
  • 5,126
  • 12
  • 34
  • 40
  • Works for me, even if the file is not executable. Try creating a pain file in /etc/init.d and see if it shows up in zsh tab completion. – Bryce Nov 25 '11 at 17:54

2 Answers2

15

you can use the following command to add all listed scripts in /etc/init.d/ to the service command:

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

-W will create word list from the ($)specified path which 'service' will use for auto-complete.

Kjuly
  • 34,476
  • 22
  • 104
  • 118
Koby
  • 837
  • 7
  • 11
4

Make sure myserviced is "executable." (i.e., chmod +x /etc/init.d/myserviced)

The completion lists all executable files in /etc/init.d, while service itself may work regardless of the permission.

yibe
  • 3,939
  • 2
  • 24
  • 17