sindresorhus / pure

Pretty, minimal and fast ZSH prompt
MIT License
13.19k stars 978 forks source link

Feat: Add option to disable `@hostname` in prompt #614

Open acantepie opened 3 years ago

acantepie commented 3 years ago

I want to change user@hostname on prompt , is it possible to doing that ?

sindresorhus commented 3 years ago

Change it how exactly?

acantepie commented 3 years ago

I have installed pure theme on my docker image, i got this prompt :

docker@58862c73050e ~
❯ 

I want hide the hostname part to display only "docker ~"

sindresorhus commented 3 years ago

Per https://github.com/sindresorhus/pure/pull/564#issuecomment-774709842, we are open to adding an option for this.

acantepie commented 3 years ago

@sindresorhus Can't you just hide hostname if we are on container ?

Replace line on file : https://github.com/sindresorhus/pure/blob/main/pure.zsh

# Show `username@host` if inside a container and not in GitHub Codespaces.
    [[ -z "${CODESPACES}" ]] && prompt_pure_is_inside_container && username='%F{$prompt_pure_colors[user]}%n%f'"$hostname"

By

# Show `username@host` if inside a container and not in GitHub Codespaces.
    [[ -z "${CODESPACES}" ]] && prompt_pure_is_inside_container && username='%F{$prompt_pure_colors[user]}%n%f'
mafredri commented 3 years ago

@acantepie while I can appreciate the (somewhat) aesthetic improvement, how would you differentiate between two open containers? We'd also have to adjust the logic for the root user which, without changes, would display the hostname. Removing the hostname there would IMO also create a color-imbalance (only the white username).

acantepie commented 3 years ago

Indeed, I have finally define a custom hostname on my docker-compose.

poetaman commented 2 years ago

@sindresorhus Is it possible to always show username@hostname, even when I have not ssh'ed into a machine?

sindresorhus commented 2 years ago

@reportaman Anything is possible by modifying the prompt yourself, but it's not something we plan to support built-in.

mafredri commented 2 years ago

@sindresorhus what's the action-point for this issue? I'm not entirely sure if it's adding an option for disabling the showing of @hostname, or to detect hostname == hostname between host and container (as per https://github.com/sindresorhus/pure/pull/564#issuecomment-774739621)?

Of the two, I think only the former is possible.

sindresorhus commented 2 years ago

@mafredri The former.

Tr0nJ4volta commented 1 year ago

@sindresorhus I would second @poetaman's ask for an option to always show the user@host in the prompt (where it normally would be). In a hasty look, I don't see a way other than to rewrite the function (i.e., prompt_pure_state_setup).

I am happy to open up a new issue and/or submit a PR.