pyenv / pyenv-virtualenv

a pyenv plugin to manage virtualenv (a.k.a. python-virtualenv)
MIT License
6.37k stars 403 forks source link

Add fish prompt changing #475

Closed romirk closed 9 months ago

romirk commented 9 months ago

Hi! I use pyenv every day, and it is truly a lifesaver. The only thing that bugs me is the fact that activating a virtual environment does not change the prompt in fish. I have introduced this fix which caches the old prompt and displays a new one with the appropriate prefix.

> pyenv virtualenv 3.12 test 
> pyenv activate test
(test) > pyenv virtualenv 3.12 test1
(test) > pyenv activate test1
(test1) > pyenv deactivate
> 

Note: old prompt is cached in _pyenv_old_prompt. It is automatically erased during deactivation and accounted for during activation.

I hope this is useful to everyone else! Thanks for your consideration.

native-api commented 9 months ago

I hope this is useful to everyone else!

It certainly is!

Please also adjust the tests to correspond to the changed code though :slightly_smiling_face:

romirk commented 9 months ago

Please also adjust the tests to correspond to the changed code though 🙂

I've added them now and tests pass locally.