prompt: yellow env_name (#5457)

### Motivation

When interact with default prompt I noticed that`env_name` has no color
and when you type command or see the output it mix with `env_name`
visually. Prompt is not highlighted when `env_name` has default color.

### Before

Output and env_name are visually mixed:

<img width="900" alt="image"
src="https://github.com/xonsh/xonsh/assets/1708680/c843388e-6e72-4fba-ab0f-6cd3fb023cd2">


### After

Output and env_name are visually distinct:

<img width="918" alt="image"
src="https://github.com/xonsh/xonsh/assets/1708680/09f45cd8-63d1-479a-bfab-c8063cf03aeb">



## For community
⬇️ **Please click the 👍 reaction instead of leaving a `+1` or 👍
comment**

---------

Co-authored-by: a <1@1.1>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Andy Kipp 2024-05-29 04:25:21 +02:00 committed by GitHub
parent 1f960b2a8d
commit 1feab91935
Failed to generate hash of commit
3 changed files with 27 additions and 4 deletions

View file

@ -0,0 +1,23 @@
**Added:**
* <news item>
**Changed:**
* Prompt: ``env_name`` will have yellow color by default.
**Deprecated:**
* <news item>
**Removed:**
* <news item>
**Fixed:**
* <news item>
**Security:**
* <news item>

View file

@ -169,7 +169,7 @@ class Aliases(cabc.MutableMapping):
# only once.
if (
isinstance(value, cabc.Iterable)
and hasattr(value, '__len__')
and hasattr(value, "__len__")
and len(value) > 1
and (isinstance(mod := self._raw.get(str(value[0])), SpecModifierAlias))
):

View file

@ -142,20 +142,20 @@ def default_prompt():
"""Creates a new instance of the default prompt."""
if xp.ON_CYGWIN or xp.ON_MSYS:
dp = (
"{env_name}"
"{YELLOW}{env_name}{RESET}"
"{BOLD_GREEN}{user}@{hostname}"
"{BOLD_BLUE} {cwd} {prompt_end}{RESET} "
)
elif xp.ON_WINDOWS and not xp.win_ansi_support():
dp = (
"{env_name}"
"{YELLOW}{env_name}{RESET}"
"{BOLD_INTENSE_GREEN}{user}@{hostname}{BOLD_INTENSE_CYAN} "
"{cwd}{branch_color}{curr_branch: {}}{RESET} "
"{BOLD_INTENSE_CYAN}{prompt_end}{RESET} "
)
else:
dp = (
"{env_name}"
"{YELLOW}{env_name}{RESET}"
"{BOLD_GREEN}{user}@{hostname}{BOLD_BLUE} "
"{cwd}{branch_color}{curr_branch: {}}{RESET} "
"{RED}{last_return_code_if_nonzero:[{BOLD_INTENSE_RED}{}{RED}] }{RESET}"