简体   繁体   中英

Adding init.d service (chkconfig / autocomplete in shell)

I've made a startup script, (ie 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

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.

Make sure myserviced is "executable." (ie, 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM