mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 08:24:40 +01:00

* refactor: remove usage of global variables in abbrevs.py * chore: add flake8-mutable to prevent mutable defaults * fix: abbrevs expand test * refactor: add xonsh session singleton * refactor: fix circular errors when using xonshSession as singleton * refactor: remove black magicked builtin attributes * style: black format tests as well * refactor: update tests to use xonsh-session singleton * refactor: update abbrevs to not use builtins * test: remove DummyCommandsCache and patch orig class * fix: failing test_command_completers * test: use monkeypatch to update xession fixture * fix: failing test_pipelines * fix: failing test_main * chore: run test suit as single invocation * test: fix tests/test_xonsh.xsh * refactor: remove builtins from docs/conf.py * fix: mypy error in jobs * fix: test error from test_main * test: close xession error in test_command_completers * chore: use pytest-cov for reporting coverage this will include subprocess calls, and will increase coverage * style:
44 lines
1,016 B
Python
44 lines
1,016 B
Python
from xonsh.tools import ON_WINDOWS as _ON_WINDOWS
|
|
from xonsh.built_ins import XSH
|
|
|
|
|
|
def _ret_code_color():
|
|
if XSH.history.rtns:
|
|
color = "blue" if XSH.history.rtns[-1] == 0 else "red"
|
|
else:
|
|
color = "blue"
|
|
if _ON_WINDOWS:
|
|
if color == "blue":
|
|
return "{BOLD_INTENSE_CYAN}"
|
|
elif color == "red":
|
|
return "{BOLD_INTENSE_RED}"
|
|
else:
|
|
if color == "blue":
|
|
return "{BOLD_BLUE}"
|
|
elif color == "red":
|
|
return "{BOLD_RED}"
|
|
|
|
|
|
def _ret_code():
|
|
if XSH.history.rtns:
|
|
return_code = XSH.history.rtns[-1]
|
|
if return_code != 0:
|
|
return "[{}]".format(return_code)
|
|
return None
|
|
|
|
|
|
def _update():
|
|
|
|
env = XSH.env
|
|
|
|
env["PROMPT"] = env["PROMPT"].replace(
|
|
"{prompt_end}{RESET}", "{ret_code_color}{ret_code}{prompt_end}{RESET}"
|
|
)
|
|
|
|
flds = env["PROMPT_FIELDS"]
|
|
flds["ret_code_color"] = _ret_code_color
|
|
flds["ret_code"] = _ret_code
|
|
|
|
|
|
# xontrib loads updates context
|
|
_update()
|