Lxd autocomplete commands in Pop!_OS

I have lxd installed on an Ubuntu server in the cloud and on my personal Pop!_OS desktop computer. Both are installed using the snap package. The issue is that on the Ubuntu server, I have command autocompletion (pressing tab to complete lxd/lxc commands like lxc sta and hit TAB to produce lxc start) but I don’t have it on Pop!_OS.

Does anyone know how to add this functionality?

Does running . /etc/bash_completion fix things somehow?

Normally for bash completion to work, there should be two files in /usr/share/bash-completion:

  • /usr/share/bash-completion/completions/lxd.lxc
  • /usr/share/bash-completion/completions/lxc

Which combined with your shell loading /etc/bash_completion should result in the completion working.

The files are there.

victoitor@victoitor-escritorio:~$ ls -l /usr/share/bash-completion/completions/lx*
lrwxrwxrwx 1 root root  7 jul 11 18:43 /usr/share/bash-completion/completions/lxc -> lxd.lxc
lrwxrwxrwx 1 root root 45 jul 11 18:43 /usr/share/bash-completion/completions/lxd.lxc -> 

I have no clue what that command does, as I have never seen a command with a dot like that in the beginning, but I did run it exactly as you said and it didn’t fix it.

victoitor@victoitor-escritorio:~$ ls -l /etc/bash_completion
-rw-r--r-- 1 root root 45 nov 11  2021 /etc/bash_completion
victoitor@victoitor-escritorio:~$ cat /etc/bash_completion
. /usr/share/bash-completion/bash_completion
victoitor@victoitor-escritorio:~$ . /etc/bash_completion

Just noticed something interesting. Installed the juju snap and autocompletion works fine for it on the same computer. Thought it might be a general snap issue with Pop!_OS, but it is not.