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

Remove pwgen dependency #166

Closed hauntsaninja closed 2 years ago

hauntsaninja commented 2 years ago

We seem to make pretty minimal use of pwgen, and since it's a little bit bothersome to have an additional install everywhere I set up my shell, I figured a couple lines of rolling our own might be better.

Fixes #165

hauntsaninja commented 2 years ago

Oh, looks like someone else also filed #165

hauntsaninja commented 2 years ago

I added a test for string length.

I then stumbled across some interesting zsh behaviour. I thought I'd add a assert "$(randstr)" not_equal_to "$(randstr)", but to my surprise, this test failed. It looks like zsh's behaviour with RANDOM is kind of weird: https://stackoverflow.com/a/63559416. I don't think this affects our logic, but we could also switch to python -c "import string, random; print(''.join(random.choice(string.ascii_lowercase) for _ in range(4)))" — let me know!

MichaelAquilina commented 2 years ago

I added a test for string length.

I then stumbled across some interesting zsh behaviour. I thought I'd add a assert "$(randstr)" not_equal_to "$(randstr)", but to my surprise, this test failed. It looks like zsh's behaviour with RANDOM is kind of weird: https://stackoverflow.com/a/63559416. I don't think this affects our logic, but we could also switch to python -c "import string, random; print(''.join(random.choice(string.ascii_lowercase) for _ in range(4)))" — let me know!

Seems like there might be a risk that we end up with shadowed virtualenv names if we are not careful. I think it would be preferable to use python in this case :)

MichaelAquilina commented 2 years ago

Thanks for the changes @hauntsaninja :)