Open StanSvec opened 1 year ago
Oh so simple, thanks! I came up with a naive solution:
_FIRST_PROMPT = True
def _starship_prompt(cfg=None):
global _FIRST_PROMPT
with __xonsh__.env.swap({'STARSHIP_CONFIG': cfg} if cfg else {}):
prompt = __xonsh__.subproc_captured_stdout([
'starship', 'prompt',
'--status', str(int( __xonsh__.history[-1].rtn)) if len(__xonsh__.history) > 0 else '0',
'--cmd-duration' , str(int((__xonsh__.history[-1].ts[1] - __xonsh__.history[-1].ts[0])*1000)) if len(__xonsh__.history) > 0 else '0',
'--jobs', str(len(__xonsh__.all_jobs))
])
if _FIRST_PROMPT:
_FIRST_PROMPT = False
return prompt.lstrip()
return prompt
Works fine unless the screen is cleared (Ctrl + L). Is there a way how to detect execution of the clear
command, so I could add one more condition for the left strip?
Thanks!
I think you're using prompt toolkit for $SHELL
and the first way is to search there.
Hmm, I didn't even know that prompt toolkit provides shell functionality, because I don't have any experience with this library. Is it possible to access ptk
's API somehow from the prompt_starship.py
file please?
Starship prompt by default prints empty line when the terminal starts. This issue is reported here and here. Despite both issues are closed the problem hasn't been fixed yet. I'm wondering if that's something which can be additionally fixed in this xontrib? Thanks!