Skip to content

Commit dfbb579

Browse files
committed
Do not leave imports like "Path" around for the interactive session
1 parent cdc16e2 commit dfbb579

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

xontrib/prompt_starship.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
"""Starship cross-shell prompt in xonsh shell. """
22

3-
import sys
4-
import os
5-
from pathlib import Path
3+
import sys as _sys
4+
from pathlib import Path as _Path
65

76

87
__xonsh__.env['STARSHIP_SHELL'] = 'xonsh'
98
__xonsh__.env['STARSHIP_SESSION_KEY'] = __xonsh__.subproc_captured_stdout(['starship','session']).strip()
109

1110

1211
def _starship_prompt(cfg: str) -> None:
12+
import os
1313
with __xonsh__.env.swap({'STARSHIP_CONFIG': cfg} if cfg else {}):
1414
return __xonsh__.subproc_captured_stdout([
1515
'starship', 'prompt',
@@ -25,9 +25,9 @@ def _starship_prompt(cfg: str) -> None:
2525

2626
_left_cfg = __xonsh__.env.get('XONTRIB_PROMPT_STARSHIP_LEFT_CONFIG' , __xonsh__.env.get('STARSHIP_CONFIG' , ''))
2727
if _left_cfg:
28-
_left_cfg = Path(_left_cfg).expanduser()
28+
_left_cfg = _Path(_left_cfg).expanduser()
2929
if not _left_cfg.exists():
30-
print(f"xontrib-prompt-starship: The path doesn't exist: {_left_cfg}", file=sys.stderr)
30+
print(f"xontrib-prompt-starship: The path doesn't exist: {_left_cfg}", file=_sys.stderr)
3131

3232
__xonsh__.env['PROMPT_FIELDS']['starship_left'] = lambda: _starship_prompt(_left_cfg)
3333
if _replace:
@@ -36,21 +36,21 @@ def _starship_prompt(cfg: str) -> None:
3636

3737
_right_cfg = __xonsh__.env.get('XONTRIB_PROMPT_STARSHIP_RIGHT_CONFIG', '')
3838
if _right_cfg:
39-
_right_cfg = Path(_right_cfg).expanduser()
39+
_right_cfg = _Path(_right_cfg).expanduser()
4040
if _right_cfg.exists():
4141
__xonsh__.env['PROMPT_FIELDS']['starship_right'] = lambda: _starship_prompt(_right_cfg)
4242
if _replace:
4343
__xonsh__.env['RIGHT_PROMPT'] = '{starship_right}'
4444
else:
45-
print(f"xontrib-prompt-starship: The path doesn't exist: {_right_cfg}", file=sys.stderr)
45+
print(f"xontrib-prompt-starship: The path doesn't exist: {_right_cfg}", file=_sys.stderr)
4646

4747

4848
_bottom_cfg = __xonsh__.env.get('XONTRIB_PROMPT_STARSHIP_BOTTOM_CONFIG', '')
4949
if _bottom_cfg:
50-
_bottom_cfg = Path(_bottom_cfg).expanduser()
50+
_bottom_cfg = _Path(_bottom_cfg).expanduser()
5151
if _bottom_cfg.exists():
5252
__xonsh__.env['PROMPT_FIELDS']['starship_bottom_toolbar'] = lambda: _starship_prompt(_bottom_cfg)
5353
if _replace:
5454
__xonsh__.env['BOTTOM_TOOLBAR'] = '{starship_bottom_toolbar}'
5555
else:
56-
print(f"xontrib-prompt-starship: The path doesn't exist: {_bottom_cfg}", file=sys.stderr)
56+
print(f"xontrib-prompt-starship: The path doesn't exist: {_bottom_cfg}", file=_sys.stderr)

0 commit comments

Comments
 (0)