Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prompt not displaying in pixi shell #384

Closed
2 tasks done
twrightsman opened this issue Oct 9, 2023 · 9 comments · Fixed by #385 or #388
Closed
2 tasks done

prompt not displaying in pixi shell #384

twrightsman opened this issue Oct 9, 2023 · 9 comments · Fixed by #385 or #388
Labels
bug Something isn't working

Comments

@twrightsman
Copy link
Contributor

Checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pixi, using pixi --version.

Reproducible example

With export PS1="${PIXI_PROMPT}${PS1}" in .bashrc:

$ pixi shell
$

Issue description

I assume this is because $PIXI_PROMPT is not defined when the .bashrc is sourced, because it seems defined in the temp file sourced after the shell is started. Following this logic, running pixi shell twice leads to the prompt appearing:

$ pixi shell
$ pixi shell
(prompt) $

Expected behavior

$ pixi shell
(prompt) $
@twrightsman twrightsman added the bug Something isn't working label Oct 9, 2023
@twrightsman twrightsman changed the title pixi prompt no longer displaying after pixi shell prompt not displaying in pixi shell Oct 9, 2023
@ruben-arts
Copy link
Contributor

This is indeed a result of the change in how the shell works. You can do export PS1='$(echo $PIXI_PROMPT)'"$PS1" But that might give a really stange double result on the prompt.

Going to look into it asap, as this is properly broken.

@ruben-arts
Copy link
Contributor

Also a really nice improvement would be to use starship.rs, they have a really nice integration for conda aswell!

@ruben-arts
Copy link
Contributor

Found a way that works, but its not the shortest.

# Avoid overwriting other prompt commands (like the one from starship.rs).
if [[ -z $PROMPT_COMMAND ]]; then
    # Get original PS1
    export ORIG_PS1="${ORIG_PS1:-$PS1}";
    # Set the PROMPT_COMMAND to generate the prompt everytime before the prompt is created.
    export PROMPT_COMMAND='PS1="${PIXI_PROMPT}${ORIG_PS1}"'
fi

@twrightsman
Copy link
Contributor Author

I tried the workaround but it broke the Conda prompt, just a heads up 😄

@ruben-arts
Copy link
Contributor

@twrightsman Ah thanks for testing, I'm not sure what the issue is. Could you share the result you get in your terminal?

@ruben-arts
Copy link
Contributor

Ah @baszalmstra correctly noted that you are talking about the above mentioned workaround, and not the PR I've been working on. Assuming the conda activation also updates the PROMPT_COMMAND this might indeed break other behavior. I hope the #385 will fix it properly for you.

@twrightsman
Copy link
Contributor Author

Sorry for the confusion @ruben-arts ! Yes, looking foward to #385 merging

baszalmstra added a commit that referenced this issue Oct 13, 2023
Depends on mamba-org/rattler#375 to build

Changes the way the shell prompts are overwriten. These are now hard
coded scripts per shell implementation.

Closes #384

---------

Co-authored-by: Bas Zalmstra <zalmstra.bas@gmail.com>
@ruben-arts
Copy link
Contributor

#388

@ruben-arts ruben-arts reopened this Oct 13, 2023
ruben-arts added a commit that referenced this issue Oct 17, 2023
Previously the prompt wouldn't update if you changed dir. 
This now reruns the prompt every time it prints

Closes #384
@twrightsman
Copy link
Contributor Author

Thanks so much @ruben-arts! v0.6.0 works great

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants