Tab completion for snaps


Starting with snapd 2.30, commands and aliases packaged in snaps are able to perform tab-completion in the bash shell, and in the future that same mechanism may be enabled in other shells as well.

For this to work, a completer key must be specified under the application scope in snap.yaml or snapcraft.yaml, pointing to a bash completion snippet (that would in traditional packaging be dropped in /usr/share/bash-completion/completions). With that, snapd will create the necessary system setup to run the completer script confined. The completer must be for the full app name (<snap>.<app>), without considering aliases.

Two sample snaps that implement this are the http and test-snapd-complexion (edge) snaps.

Snapcraft has had support for the completer attribute of snap apps since version 2.33.

Debugging tab completion of a strict snap can be hard, so we wrote a guide for it.

Extending this tab completion mechanism to other shells (zsh for example) is relatively simple. All that is needed is a marshaller of the completion request. See in the snapd source for details.

Classic confinement for bootstack-ops snap
Snap Documentation
Snap Documentation (page deprecated)

@enzoaguado you edited to contain things that are incorrect and misleading :frowning:

I reverted your edit, and then tried to address your original comment. Unfortunately you deleted your comment so I had to work from memory. Hopefully I remembered correctly.


You don’t use snap run to call your snapped command from inside your completer. You’re already confined; in a strictly confined snap, running snap will fail.