containers / toolbox

Tool for interactive command line environments on Linux
https://containertoolbx.org/
Apache License 2.0
2.38k stars 208 forks source link

Rethink the prompt #576

Open allanday opened 3 years ago

allanday commented 3 years ago

One of the main challenges using toolbox is knowing which environment your prompt is in. Our current approach to this:

image

Various issues here:

This is a somewhat complicated topic, since we have to think about the overall structure of the prompt. We also maybe need to think about the various tools that exist for doing fancy prompts.

allanday commented 3 years ago

I was recently playing around with some ideas for this, and came up with:

image

The initial "f33" with coloured background is supposed to indicate the current toolbox. This would require that we ensure that there's a short name for each toolbox. We could also assign a different colour to each toolbox, to use as the background for this short ID.

The format for the rest of the prompt was: <current project folder> <git branch> <current dir>, but I suspect that that's out of scope for this ticket.

tpopela commented 3 years ago

I will link https://github.com/containers/podman/issues/6192 here as this could help us in improving the prompt experience.

rrichardson commented 3 years ago

This is not a universal solution, but I added these three lines to my starship config:

[env_var]
variable = "containers"
format = "[🔧](fg:177)"

And now my prompt has a wrench when I'm in a podman shell (and have access to my home dir)

(once https://github.com/containers/podman/issues/6192 is completed, the prompt can be a lot more precise)

runiq commented 2 years ago

Now that https://github.com/containers/podman/issues/6192 is done, this is what I use with Starship to have the current toolbox name (and the  ) in my prompt:

[custom.toolbox]
shell = [ "sh", "--norc" ]
command = """ grep -Po 'name="\\K[^"]+' /run/.containerenv """
when = "test -f /run/.containerenv"
format = "[ $output]($style) "
style = "#808080"