prefix-dev / pixi

Package management made easy
https://pixi.sh
BSD 3-Clause "New" or "Revised" License
2.41k stars 137 forks source link

Integrate setting the prompt so that the user sees they are in a pixi shell #219

Closed ruben-arts closed 8 months ago

ruben-arts commented 1 year ago

When moving into a pixi shell it can be convenient to see that the shell is active.

[rarts@fedora test] $ pixi shell
(test) [rarts@fedora test] $ exit
[rarts@fedora test] $ 

NOTE: to get this to work you have to run pixi completion in your shells activation script, e.g. .bashrc or .zshrc. There are examples in the docs

Currently supported: Shell Supported
Bash :white_check_mark:
Zsh :white_check_mark:
Fish :white_check_mark:
Xonsh :white_check_mark:
Powershell :white_check_mark:
CMD.exe :white_check_mark:
kolibril13 commented 11 months ago

Yep, I totally agree with this, I think this is super useful! For me, this does not work in Zsh on an Mac M1, as can be seen in this screenshot.

image

Also, I'm wondering why it's possible to activate the shell with micromaba and conda, as can also be seen in the screenshot. With that approach, I however get the full path (/Users/jan-hendrik/projects/trying-pixi/.pixi/env) , where it would be nice to only get the relative path (.pixi/env)

Made with

which python

pixi shell
which python
exit

conda activate .pixi/env
which python
conda deactivate

micromamba activate .pixi/env
which python
micromamba deactivate
traversaro commented 10 months ago

Currently supported: Shell Supported Bash Zsh Fish ❌ Xonsh ❌ Powershell ❌ CMD.exe ❌

Just to understand, the feature is expected to work on bash/zsh with pixi 0.2.0 ? I am asking as it is not working for me on Bash/WSL2, so if it useful I can provide debug info.

ruben-arts commented 10 months ago

Just to be sure I added a note in this issue, that you need to add the pixi completion to your rc files. Are you @traversaro @kolibril13 both running that resulting script before you run pixi shell ?

This is my result using v0.2.0:

[rarts@fedora test]$ pixi shell
(test) [rarts@fedora test]$ exit 
exit
[rarts@fedora test]$ 

@kolibril13 The fact that all tools can activate the environment is because we all implement the "conda spec" so its "just" a conda environment. pixi does nothing special to those environments. The magic is in the interaction with those environments. The default behaviour of the conda environments is to use the "name" or the path but since we don't store a global list of names for the environments we can't use the same logic that conda uses to get the name in the prompt.

traversaro commented 10 months ago

Just to be sure I added a note in this issue, that you need to add the pixi completion to your rc files. Are you @traversaro @kolibril13 both running that resulting script before you run pixi shell ?

I was not, indeed after doing that the feature is working for me, thanks!

ruben-arts commented 8 months ago

This has been fixed in #385