Why don't custom upstart job names tab complete in the service command?

Solution 1:

Every package that provides a standard daemon using upstart is required to provide a symlink in /etc/init.d by Debian policy. So autocompletion for sudo service name already works. Make sure that you have the bash-completion package installed if you're having problems.

If you are creating your own upstart jobs, then symlink /etc/init.d/your_job to /lib/init/upstart-job like the other upstart jobs are doing already. This will make your own jobs work the same way.

There are special upstart jobs in /etc/init that do not have a corresponding entry in /etc/init.d. These are an exception. From Debian Policy:

An exception to this rule is scripts or jobs provided by the init implementation itself; such jobs may be required for an implementation-specific equivalent of the /etc/rcS.d/ scripts and may not have a one-to-one correspondence with the init scripts.

These exceptions do not currently work with bash-completion. However, you can use start, stop, restart and reload directly without service, and autocompletion will work. For example, sudo start shut correctly autocompletes. But you shouldn't normally need to directly call upstart jobs that do not have a corresponding init.d entry.

Note: I tested this on Saucy. If support doesn't appear in an older release, perhaps it is not available there (but you'll get it soon when you upgrade to a sufficiently new release).