mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 16:34:47 +01:00
some lookup fixes
This commit is contained in:
parent
1d3cadb532
commit
9d086229ae
3 changed files with 18 additions and 26 deletions
|
@ -5,9 +5,8 @@
|
|||
|
||||
**Changed:**
|
||||
|
||||
* ``env_name`` prompt filed no longer includes the pre- and post-fix characters
|
||||
itself.
|
||||
* The default prompt now starts with ``"{env_prefix}{env_name}{env_postfix}"``.
|
||||
* ``env_name`` prompt field now looks up the pre- and post-fix characters,
|
||||
rather than relying on hard-coded values/
|
||||
|
||||
**Deprecated:**
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ from xonsh.prompt.cwd import (
|
|||
_dynamically_collapsed_pwd,
|
||||
)
|
||||
from xonsh.prompt.job import _current_job
|
||||
from xonsh.prompt.env import env_name, env_prefix, env_postfix, vte_new_tab_cwd
|
||||
from xonsh.prompt.env import env_name, vte_new_tab_cwd
|
||||
from xonsh.prompt.vc import current_branch, branch_color, branch_bg_color
|
||||
from xonsh.prompt.gitstatus import gitstatus_prompt
|
||||
|
||||
|
@ -102,8 +102,8 @@ def PROMPT_FIELDS():
|
|||
branch_bg_color=branch_bg_color,
|
||||
current_job=_current_job,
|
||||
env_name=env_name,
|
||||
env_prefix=env_prefix,
|
||||
env_postfix=env_postfix,
|
||||
env_prefix="(",
|
||||
env_postfix=") ",
|
||||
vte_new_tab_cwd=vte_new_tab_cwd,
|
||||
gitstatus=gitstatus_prompt,
|
||||
)
|
||||
|
@ -113,20 +113,20 @@ def default_prompt():
|
|||
"""Creates a new instance of the default prompt."""
|
||||
if xp.ON_CYGWIN or xp.ON_MSYS:
|
||||
dp = (
|
||||
"{env_prefix}{env_name}{env_postfix}"
|
||||
"{env_name}"
|
||||
"{BOLD_GREEN}{user}@{hostname}"
|
||||
"{BOLD_BLUE} {cwd} {prompt_end}{NO_COLOR} "
|
||||
)
|
||||
elif xp.ON_WINDOWS and not xp.win_ansi_support():
|
||||
dp = (
|
||||
"{env_prefix}{env_name}{env_postfix}"
|
||||
"{env_name}"
|
||||
"{BOLD_INTENSE_GREEN}{user}@{hostname}{BOLD_INTENSE_CYAN} "
|
||||
"{cwd}{branch_color}{curr_branch: {}}{NO_COLOR} "
|
||||
"{BOLD_INTENSE_CYAN}{prompt_end}{NO_COLOR} "
|
||||
)
|
||||
else:
|
||||
dp = (
|
||||
"{env_prefix}{env_name}{env_postfix}"
|
||||
"{env_name}"
|
||||
"{BOLD_GREEN}{user}@{hostname}{BOLD_BLUE} "
|
||||
"{cwd}{branch_color}{curr_branch: {}}{NO_COLOR} "
|
||||
"{BOLD_BLUE}{prompt_end}{NO_COLOR} "
|
||||
|
|
|
@ -19,24 +19,17 @@ def find_env_name():
|
|||
|
||||
|
||||
def env_name():
|
||||
"""Returns the current env_name if it non-empty."""
|
||||
"""Returns the current env_name if it non-empty, surrounded by the
|
||||
``{env_prefix}`` and ``{env_postfix}`` fields.
|
||||
"""
|
||||
env_name = find_env_name()
|
||||
if env_name:
|
||||
return env_name
|
||||
|
||||
|
||||
def env_prefix(chars="("):
|
||||
"""Returns prefix characters if the environment name is non-empty."""
|
||||
env_name = find_env_name()
|
||||
if env_name:
|
||||
return chars
|
||||
|
||||
|
||||
def env_postfix(chars=") "):
|
||||
"""Returns postfix characters if the environment name is non-empty."""
|
||||
env_name = find_env_name()
|
||||
if env_name:
|
||||
return chars
|
||||
if not env_name:
|
||||
# no environment, just return
|
||||
return
|
||||
pf = builtins.__xonsh__.shell.prompt_formatter
|
||||
pre = pf._get_field_value("env_prefix")
|
||||
post = pf._get_field_value("env_postfix")
|
||||
return pre + env_name + post
|
||||
|
||||
|
||||
def vte_new_tab_cwd():
|
||||
|
|
Loading…
Add table
Reference in a new issue