From 1feab91935b98209da9bb0bdcc76af7e042dcaa1 Mon Sep 17 00:00:00 2001 From: Andy Kipp Date: Wed, 29 May 2024 04:25:21 +0200 Subject: [PATCH] prompt: yellow env_name (#5457) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### 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: image ### After Output and env_name are visually distinct: image ## 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> --- news/prompt_env_name_yel.rst | 23 +++++++++++++++++++++++ xonsh/aliases.py | 2 +- xonsh/prompt/base.py | 6 +++--- 3 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 news/prompt_env_name_yel.rst diff --git a/news/prompt_env_name_yel.rst b/news/prompt_env_name_yel.rst new file mode 100644 index 000000000..1c06efc1f --- /dev/null +++ b/news/prompt_env_name_yel.rst @@ -0,0 +1,23 @@ +**Added:** + +* + +**Changed:** + +* Prompt: ``env_name`` will have yellow color by default. + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* + +**Security:** + +* diff --git a/xonsh/aliases.py b/xonsh/aliases.py index 6e6a65038..a960b7ca5 100644 --- a/xonsh/aliases.py +++ b/xonsh/aliases.py @@ -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)) ): diff --git a/xonsh/prompt/base.py b/xonsh/prompt/base.py index 90af7e855..23176f9b6 100644 --- a/xonsh/prompt/base.py +++ b/xonsh/prompt/base.py @@ -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}"