setv: Lightweight Python virtual environment manager
Update [March 30, 2016]: I created setV as a separate project with installer and readme. This post is quite old.
I like to have a separate virtualenv for each python project. This
ends up having virtual-environments for each project that I often find
difficult to manage. All my virtual-environments resides in
~/virtualenvs directory but to activate/deactivate a virtual
environment every time is a tedious job.
An easy solution to this is to install virtualenvwrapper, but then I
have run commands like
mkvirtualenv. I don’t want to do
that. Can I manage virtual environment using single command?. Luckily
I have Bash function I find very handy. It lists all available virtual
environments and can switch the environment as needed.
List all virtual environment
setv [TAB] [TAB] # or setv -l
Switch virtual environment
Create new virtual environment
setv -n <NEW-VIRTUAL-ENVIRONMENT-NAME>
setv -n foobar
Delete existing virtual environment
setv -d <EXISTING-VIRTUAL-ENVIRONMENT-NAME>
setv -d foobar
Deactivate virtual environment
The script is available here and can be downloaded via
VIRTUAL_DIR_PATHvalue to your virtual environments directory-path in
virtual.shfile. By default it is set to
Create a directory to hold all virtual environments
Added this line to your
.bashrcor any local rc script.