Projects are a great way to logically group together containers and I have started using them as soon as I discovered they exist, a few months ago.
I would like to propose some improvements and collect feedback from other users:
Allow working on a different projects in different terminals, that is define the scope of the project selection. I may need to work on two different projects at the same time, but as for now I need to do a switch operation if I want to issue a command on the other project.
Allow starting and moving containers in other projects without being on that project scope, for example by putting the project name before the container:
Allow listing all the projects along all the instances. There is already some work on this, details here
Give clear indication to the user of the currently selected project. A good example is Python virtualenv, that puts the environment name in the shell prompt.
It would be great to have some feedback on whether these requests make sense and if there is some effort in developing them.
That is unfortunately incredibly difficult to do and would be extremely OS specific. We’d need a config overlay which is based on the tty index, that’d be messy to do and for folks to understand and would only really work on Linux (whereas the CLI also works on macOS and Windows).
The closest you could get to that I suspect is by having completely different config dirs and manually setting LXD_CONF in your environment to point to the right one for a particular terminal.
You should be able to do something like that by figuring out the right syntax for your shell of choice. For bash, you usually need to set PS1 to some odd escape sequence pattern. The main downside to this is that every single time the prompt is rendered, it will be calling some subcommands, so this can get an extremely high overhead.
I use this to show git branches here (which means git-branch is effectively called every time the prompt renders:
# Prompt syntax
parse_git_branch() {
BRANCH=$(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/')
if [ "x$BRANCH" != "x" ]; then
echo " ${BRANCH}"
fi
}
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[01;31m\]$(parse_git_branch)\[\033[00m\]\$ '