pyenv / pyenv-virtualenv

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

'pyenv version' replacement for prompt display, using bash-only functions #411

Open fmeynadier opened 3 years ago

fmeynadier commented 3 years ago

Hi,

Not really an issue, but an idea concerning the long-standing issue of prompt updating (#268, #346, #385, maybe others...) I guess that one of the incentives for deprecating this feature is its slowlyness, and replaceing it with a call to 'pyenv version' every time is not any better...

On my side I use https://gitlab.com/bersace/powerline.bash and helped including support to pyenv version display in my prompt, purely using bash. I extracted the parts that concern pyenv and assembled a minimal script that you can find here : https://gist.github.com/fmeynadier/23869cdbdaab732396eb46e1ec545dde

It implements the algorithm described in the readme to determine the pyenv virtualenv version, and in my experience it returns the answer ~10 times faster than 'pyenv version': you can feel the difference on the prompt reactivity. Of course it uses bash so porting to other shells may require fine-tuning.