sindresorhus / pure

Pretty, minimal and fast ZSH prompt
MIT License
13.12k stars 971 forks source link

Add check for diamond character when inside a toolbox #623

Closed gbrlgn closed 2 years ago

gbrlgn commented 2 years ago

A simple line to check if the user is currently inside a Toolbox container, by checking if the hostname is indeed toolbox and re-checking if the user actually has Toolbox installed, in which case there would be no reason for them to name their machine "toolbox"; and then add the diamond indicator from the default Toolbox prompt in place of the username, just before the path. toolbox

Diamond on the same line as PROMPT_PURE_SYMBOL, as sugested by @mafredri new

mafredri commented 2 years ago

Also, this seems like it kind of steps on virtualenv territory, and as such I think it would make more sense (out of a consistency perspective) to show ⬢ before the prompt symbol.

gbrlgn commented 2 years ago

Before we go any further with this PR, I'd like to understand how ⬢ is indicative of Toolbox? I'm totally unfamiliar with it myself.

And what does it currently look like when you enter Toolbox, pre-patch?

When you create a toolbox, it creates a podman container (in my case a Fedora image) where you can install stuff in isolation from your main system. It will use a default bash prompt with that diamond at the beginning. If you install zsh inside this container, as it has access to your filesystem for development purposes, it sources your .zshrc and displays the pure prompt as it is, with no indicative whatsoever of the user being inside the toolbox (unless they echo $HOSTNAME).

gbrlgn commented 2 years ago

Also, this seems like it kind of steps on virtualenv territory, and as such I think it would make more sense (out of a consistency perspective) to show ⬢ before the prompt symbol.

I chose that placement, right at the beginning, to be familiar to the average default-prompt Toolbox user, but I can amend another commit placing it where you specified, if needed!

Default prompt for your consideration: blog.christophersmart.com/2020/04/11/easy-containers-on-fedora-with-toolbox/