Hi!
First of all, it’s amazing that you dug into the shell completion. It helps a lot into the usability of LXD.
You are using lxc exec
, which means that you are using LXD instead of LXC 1.0 (see Comparing LXD vs. LXC).
In LXC 1.0 there has been a lxc-console
command for quite some time, which could also be reused on LXD (https://github.com/lxc/lxd/issues/1129).
In LXD, since last autumn (I think LXD version 2.17 or newer), you can use lxc console
to get a console to the container. The stock LXD version in Ubuntu 16.04 LTS does not have lxc console
so you would either need to upgrade to the snap version of LXD, or install LXD from the backports
repository.
Having said that, here are the new possibilities:
Shell access to container | tty |
---|---|
lxc exec c1 – sh | not a tty |
lxc console c1 | /dev/console |
enter_container c1 | /dev/pts/0 |
I do not fully understand how it gets the /dev/pty/0 tty.
You mention that your contribution is the bash autocomplete
. I think it would be great to have this autocompletion for the full set of LXD subcommands, especially for lxc config
which tends to get complicated with the many options. The user would type, for example, lxc config <TAB><TAB>
and then get a list of keywords that are suitable to come after lxc config
.
The jq
requirement could be an issue. In LXD 2.21, there is a new format, csv
. The first field is the container name and the second is either RUNNING
or STOPPED
. Therefore, it would be possible to avoid jq
outright in LXD 3.0. In older LXD, it should be possible to use some shell commands to extract the container names.