Tab-completion out of the box?

We have the new /usr/lib/snapd/ which is great. However it looks like it is not yet part of the /etc/profile.d defaults ? If this is the case, is there any reason against adding it to the packages? For the re-exec case we need to think a bit more how to source the file, but maybe . /snap/core/current/usr/lib/snapd/ is safe everywhere (except on systems that do not put /snaps on /snaps).

Ah, I hadn’t thought of putting it there. I’d thought of patching bash-completion itself (upstream) once we actually shipped (we don’t yet). But profile.d is probably better, as long as we can ensure it’s loaded after in the same directory.

Great, thanks a lot! We are now shipping it :slight_smile:

$ ls -l /snap/core/2381/usr/lib/snapd/ 
-rw-r--r-- 1 root root 4805 Jul  5 17:47 /snap/core/2381/usr/lib/snapd/

And 2381 is in stable.

So lets add the missing integration bits. Ideally we write the profile.d file if we re-exec.

I mean /usr/lib/snapd/ isn’t there :slight_smile:

you lost me there. Why only if we re-exec?

Sorry, was a bit of a rush when writing my previous post.

The situation is that we have /usr/lib/snapd/ there if you are on the 2.26.9 deb package that comes from -proposed. So for the deb it is trivial to add a /etc/profile.d/ and things will be picked by nicely when you run the package.

However in the case that people use an older version of snapd (say 2.21) and only get their updates via core refreshes and re-exec we have no story yet. I was thinking we could check on snapd startup if /etc/profile.d/ is there and if not generate it and point to /snap/core/current/usr/lib/snapd/ Alternatively we could hook into snap run and generate a per-user .profile but the system-wide solution sounds cleaner to me.

Hmmm… and what would happen if we did that, and the user then upgraded to >=2.26.9?

Good point! We probably need to make sure it is written with a different name then.

@chipaca What’s the status of tab-completion overall? If it’s completely done, can we get something in #doc describing how to get snaps to auto-complete? Apologies if we already have that and my lazy search missed it.

@niemeyer tab completion snippets are in 2.27.2; 2.27.5 avoids creating them in core devices where they break. So I think it’s ready? I haven’t checked if in core devices we’re loading (meaning we don’t need the snippets there), otherwise we should.

Thanks for confirming. Would you mind to write an initial documentation topic under #doc that describes how one should go about having tab-completion on their snaps? Just something we can use as a reference whenever someone asks about how to make it work, and as a side effect also something we can announce so people know they can now do this in their existing snaps.

@evan was particularly interested in this feature so will be happy to here we are there now.

I’m afraid I was misreading the git log when I reported the versions above. Only 2.28+ will have snippets.

I’m leaving this in #upcoming because aliases don’t work yet; those are upcoming. Then we’ll be done (modulo bugs, which I still expect!).

1 Like