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
1211def _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' , '' ))
2727if _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 )
3333if _replace :
@@ -36,21 +36,21 @@ def _starship_prompt(cfg: str) -> None:
3636
3737_right_cfg = __xonsh__ .env .get ('XONTRIB_PROMPT_STARSHIP_RIGHT_CONFIG' , '' )
3838if _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' , '' )
4949if _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