I'm trying to create an alias on ZSH.
The aim of the alias is to activate a python virtualenv.
I've put a line in my .zshrc
alias SOU="source /home/andykw/.zshrc && source $(setopt extendedglob && ls -d .^git/)/bin/activate"
Often I need to change virtual environment with activating a virtual environment in one of the folder, then switching to another folder and activate another virtual environment.
Example: Let's say I'm working with the folder flask_rest
and I have to work on another project, django_rest
, I will need to deactivate the flask_rest
environment and activate the django_rest
environment.
Instead of doing it several times with the command line source <folder_name>/bin/activate
then go with another folder source <another_folder_name>/bin/activate
, I only need to type SOU
.
Hope it makes the context clearer.
PS: I'm using Ubuntu with a Windows Subsystem Linux.
activate
file that is in./*/bin/activate
? Can there be more than one? Will you not know the name of the file? Can't you just dosource .*/bin/activate
?