I was checking FSB35 yesterday, I’m fairly impressed how smooth the container integration is with the host system, especially when running graphical applications Kudos to the Silverblue team!
Something I didn’t find how to do tho - and admittedly haven’t deep dive into the Toolbox documentation yet - is how to get the name of the container in use when you enter a container through toolbox enter $CONTAINER.
Sometimes during the time I tested this cool feature, I’ve found myself switching from container to container and at some point losing track of which container I was standing in.
It would be incredibly handy if somehow we could get the name of that container to get it shown in the prompt like one can usually do by setting the PS1 variable or using tools like the wonderful Starship.rs
I’m not pretty sure, but it seems to work.
Once inside the container, issue the hostname command: sudo hostname mytoolbox
Exit and enter, now the container has its name.
Hello @bluejat,
Welcome to ask !
When I enter a toolbx container my prompt changes to reflect that …
As you can see, it is designated as toolbox, and if I installed Fish shell in it I would get my Fish shell there too. Maybe I’m missing what you want to see at the prompt.
@alciregi Hmm that would involve manual configuration and I was looking for something like @jakfrost mentions
@jakfrost This is exactly what I was looking for. Did you set up that integration by yourself, or somehow that works out of the box for you?
I’m unable to reproduce the behavior you show OOTB in SB35 (installed on a KVM VM since I’m getting acquainted with the OS before switching to it as my main OS):
Yeah, that was what I was wondering. I remember someone else discussing this somewhere on discussion.fp.o I think. It is something useful, in my case Guake usually seems to display the command issued and the pwd it was issued from, but the shell reflecting what container name would need to likely invoke a script at startup of the container to change the $PS1 and possibly $PS2. For instance when I have Fish installed it is like
I was expecting that Toolbox somehow would show the name of the container in the shell prompt, to give a proper context of the new shell execution context.
However, I understand this might not be as easy to implement as intended, since toolbox enter (which I guess is basically an alias for podman attach) has no way to drag any environment variable into a running container, at least not that I know with either podman or Docker.
It seems that in the end, the solution you proposed by changing the hostname of the container may work.
Generally speaking, I’m not fond of setting the hostname for containers, as I treat them as ephemeral execution contexts. But since we are talking here about mutable containers that are intended as long-term execution contexts, giving them a proper hostname does make sense.
I wonder if there could be a way to add this functionality to Toolbox to set the hostname of a container at creation time, maybe with podman exec or even by leveraging nsenter?
You should look at toolbox.conf the configuration file help. When you create a toolbox container, you can specify many options such as different distro, custom image, perhaps the option you desire is one. As well as giving them specific names which also highlights difference. They are intended to be “pet” containers you keep around for awhile instead of being as ephemeral and disposable as a typical container. FWIW, it (toolbx/toolbox) is written in Go and C AFAIK, and is not just a wrapper for podman. It used to be a script originally.
To quickly address some of your comments guys: @jakfrost You’re correct sir, the part of the code I saw yesterday in the repo is Go, which is beautiful. @ilikelinux I’ll take a look at it and see what I can salvage for my configs (right now I’m using Zsh + OMZ + Starship.rs, all awesome developments. I want to fall in love with Nu shell tho, time will tell). @alciregi Once again, you were correct about setting the hostname to differentiate containers. Also, nice finding with that issue!
This provides me with containers with their hostnames that match the container name itself and give me complete visibility over what environment I’m standing in at all times.
By running this:
C=(ansible aws gcp python)
for i in "${C[@]}";
do
toolbox create -c $i \
&& toolbox run -c $i sudo hostname $i \
&& toolbox run -c $i hostname \
&& echo -e "\n\n";
done
Yup, the entire package is huge, luckily you can download the font of your choice straight from the Nerd Fonts website and put them in your .local/share/fonts folder. Be sure to run fc-cache -vf after adding them to your local folder. Also, I did not layer anything. The Powerline stuff for TMUX can be downloaded and install using ‘pip’ Python package.
Everything I have is in a toolbox. I use bash while working in the CoreOS. ZSH, Oh-My-ZSH, Powerlevel10k, TMUX with Powerline bindings in a toolbox. TMUX can be used to call the ZSH shell. None of it needs to be layered.
There is a cool website where you can try each font beforehand. It can even change the theme, font size, and the programming language.