If you happen to throw most things into containers, I think this a handy trick for lazy people like us.
* It is somehow an idea inspiring from Firefox TabContainer
Here is the trick, so Gnome Terminal supports different profile and most terminal apps maybe, too. Inside profile you can execute a different program, this is what I did:
sh -c 'NEW_NAME=AG-$(shuf -n1 /usr/share/dict/words|tr -d [:punct:] ) && lxc launch images:ubuntu/18.04 $NEW_NAME && lxc exec $NEW_NAME bash'
![]() |
---|
Under menu Edit > Profile tab > edit the profile > Command tab > “Run a custom command instead of my shell” |
Open new container through profile, mine is named “New Container”, then in the same Gnome Terminal Window, you could simply open another container by opening new tabs:
To keep the environment and stuff after whatever stuff your tried and built with containers, simply copy that container, using command outside containers:
$ lxc copy AG-random-name a-new-name
At the end of the day, to clean up all auto-generated containers, just do following:
$ lxc list AG --format=csv|cut -d, -f1|xargs -I% sh -c 'lxc stop % && lxc delete %'
Put this into shell alias or a script under ~/bin as you wished.
To config lxd/lxc please check this: https://tutorials.ubuntu.com/tutorial/tutorial-setting-up-lxd-1604