MichaelAquilina / zsh-autoswitch-virtualenv

🐍 ZSH plugin to automatically switch python virtualenvs (including pipenv and poetry) as you move between directories
GNU General Public License v3.0
507 stars 80 forks source link

Allow specifying mkvenv name #189

Open philer-jambit opened 1 year ago

philer-jambit commented 1 year ago

When running mkvenv it would be great to have an optional parameter that allows overriding the default "$(basename $PWD)-$(randstr)".

Some reasons:

  1. The generated names can be kind of ugly, especially when the directory name is long. When I clone a repo with a long name I get an even longer name prepended to my prompt so I'd very much prefer an option to keep it brief. I promise I'll make sure it remains unique.
  2. There have already been noted instances where people want to check their .venv into version control, although I agree that sounds like a bad idea.
  3. Most importantly, there may be instances where I occasionally want to switch between venvs for the same project, in which case the appended random string is a poor identifier. For example I'm currently facing this as we have a branch transitioning from python 3.10 to 3.11. For this purpose I'd like to use venvs with corresponding suffixes, like "myproject-310" and "myproject-311".

The current implementation has lead me to resort to temporarily modifying the source of this script in order to get the name I want.

Side note: This is somewhat of a generalization of #174 which looks stale, I hope it's okay to open a new issue for it.

Either way, thanks for your work on this project! :)


Operating System
Linux Mint 21.1

zsh version (zsh --version)
zsh 5.8.1 (x86_64-ubuntu-linux-gnu)

autoswitch-virtualenv version
3.5.0

How is zsh-autoswitch-virtualenv installed?
oh-my-zsh

Steps to reproduce the issue

MichaelAquilina commented 1 year ago

Hello @philer-jambit this is a good idea :)

I may find some time to implement it in the future but maybe a better suggestion would be for you to give a go at implementing it yourself and opening a PR.

It shouldnt be too difficult I think!