pure icon indicating copy to clipboard operation
pure copied to clipboard

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

Open acantepie opened this issue 3 years ago • 11 comments

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

acantepie avatar Oct 11 '21 20:10 acantepie

Change it how exactly?

sindresorhus avatar Oct 12 '21 03:10 sindresorhus

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 ~"

acantepie avatar Oct 12 '21 07:10 acantepie

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

sindresorhus avatar Oct 12 '21 08:10 sindresorhus

@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'

acantepie avatar Oct 19 '21 15:10 acantepie

@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).

mafredri avatar Oct 19 '21 15:10 mafredri

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

acantepie avatar Oct 19 '21 16:10 acantepie

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

poetaman avatar Dec 14 '21 02:12 poetaman

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

sindresorhus avatar Dec 14 '21 11:12 sindresorhus

@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.

mafredri avatar Jun 05 '22 10:06 mafredri

@mafredri The former.

sindresorhus avatar Jun 05 '22 12:06 sindresorhus

@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.

Tr0nJ4volta avatar Jan 05 '23 16:01 Tr0nJ4volta