anki-code / xontrib-prompt-starship

Starship cross-shell prompt in xonsh shell.
MIT License
51 stars 8 forks source link

First `$STARSHIP_PROMPT` example doesn't to work / path not taken as absolut #13

Closed yggdr closed 3 months ago

yggdr commented 3 months ago

Using the first example of creating a short toml, setting $STARSHIP_CONFIG to a string like ~/.config/stuff.toml or $HOME/.config/other_stuff.toml does not pick up those configuration files. After experimenting with starship config a bit it seems that the value of $STARSHIP_CONFIG isn't actually taken to be an absolut path (with ~ or $HOME properly expanded), but instead an unexpanded path relative to the current directory. So starship config would try to open the non-existing file /current/working/directory/~/.config/stuff.toml.

anki-code commented 3 months ago

PR with fix is welcome!

yggdr commented 3 months ago

After looking into how xontribs work and investigating the underlying issue, I can give you two possible solutions: The short fix https://github.com/anki-code/xontrib-prompt-starship/pull/14 which only introduces a Path(...).expanduser() at one point, and the slightly longer fix https://github.com/anki-code/xontrib-prompt-starship/pull/15 which does some minor refactoring, moving the expanduser responsibility completely outside the _starship_prompt function.

I would prefer the longer version.

anki-code commented 3 months ago

Hey @yggdr! Thank you for two options. I asked question in #15 .

yggdr commented 3 months ago

I don't see a question in either PR.

anki-code commented 3 months ago
image
yggdr commented 3 months ago

Strange, I still do not see anything in the PR itself?! But to answer your question: that was a mistake when rearranging some code, apparently I didn't test thoroughly again afterwards. I corrected it to STARSHIP_CONFIG. That way, left-cfg falls back to it if no side-specific prompt is set.