agkozak / agkozak-zsh-prompt

A fast, asynchronous Zsh prompt with color ASCII indicators of Git, exit, SSH, virtual environment, and vi mode status. Framework-agnostic and customizable.
MIT License
292 stars 26 forks source link

Show hostname when inside containers too #40

Open edwintorok opened 1 year ago

edwintorok commented 1 year ago

distrobox (and other toolbox-like containers) set a hostname, and it is useful to be able to distinguish whether you are inside the container or outside. When /run/.containerenv is present then show the hostname, just as if it was an SSH-ed remote host.

agkozak commented 1 year ago

It looks as if docker creates, not /run/.containerenv, but /.dockerenv, so we would want to update that test to

if _agkozak_is_ssh || (( EUID == 0 )) || [[ -f /.dockerenv || -f /run/.containerenv ]]; then

Perhaps you could confirm that that is the case? I don't use distrobox, but that was a problem I ran into when I tried it out.

Your idea looks very clever to me. Give me a while to think if there are any downsides to using it, OK? Thanks so much.

lfromanini commented 1 year ago

I just opened an issue before checking this pull request, but I think it contemplates this subject. Please, check, if possible.