Fedora Silverblue 39 - Toolboox - Show toolbox/container name on bash PS1


I recently switched to Fedora Silverblue and I noticed that if you don’t touch the .bashrc file we can this nice prompt informing you that you’re on a toolbox (after you run toolbox enter). But I do miss my own .bashrc configuration so I switched the files and for now I all have to flag the session as a “container” is the host name changing to “toolbox”.

So is there a way to gather the actual container name and add it to my prompt? maybe an environment variable, shell formatting variable, or a toolbox/podman command?

Thank you!

Try changing the terminals behaviour to reflect your environment. For instance in the terminal program Ptyxis (it’s the future Gnome Terminal) you can launch profiles which can be your toolbox profile for instance. In fact it actually will look for the containers.
Another terminal program Terminology from Enlightenment, has profiles as well and does transparency. I’ll do some digging, but I wrote a bash article for Fedora Magazine about these prompt prettying things. My prompt stays like my normal one when in Toolbox just with “Toolbox” for the host name in my PS1.
[Edit] AFAIK Toolbox just uses your existing .bashrc file for it’s own. So to do what you’re thinking in the prompt would only require modifying your existing .bashrc in your home dir.

Screenshot of Enlightenment terminal in toolbox
Note it uses my .bashrc file for the prompt but does not have fzf installed hence the error before the toolbox prompt is displayed.

Screenshot of Ptyxis …
The menu of container terminals I can open …
and what it looks like when in toolbox …

Below is one part of my .bashrc

function is_toolbox() {
	if [ -f "/run/.toolboxenv" ]
		TOOLBOX_NAME=$(cat /run/.containerenv | grep -E '^name="' | cut -d \" -f 2)
		echo " ❱ ${TOOLBOX_NAME}"

if [ "${TOOLBOX_NAME}" ]
	export PS1="\n\[\033[35m\]⬢ \[\033[0m\][\u@\h${TOOLBOX_NAME} \W]\$ "

The result is something like that:



It’s based on the tip there: Tips and Tricks :: Fedora Docs

1 Like