This is a custom shell script I wrote in order to ease my workflow when dealing with Python Virtual Environments.
Download the activatevenv.plugin.sh into your computer.
- Download the script into
$ZSH_CUSTOM/plugins/<plugin_name>/activatevenv/. See oh-my-zsh Plugin Customization Wiki
# Use curl or download manually from https://git.io/JLBHr
(mkdir activatevenv; cd activatevenv) && curl -L --url https://git.io/JLBHr --output ./activatevenv/activatevenv.plugin.zsh- Edit your
~/.zshrc:
…
# Add activatevenv to your list of plugins and restart the terminal.
plugins=(... , activatevenv)
…- Copy and paste the
activatevend.plugin.shscript to the bottom of your~/.bashrcor~/.zshrcand restart your terminal.
Simply cd into a project directory with a python virtual environment setup (with any of these names: venv/, .venv/, env or .env), and the script will activate it automatically for you (just as you would do with source ./venv/bin/activate).
If you are creating a new virtualenv, run python -m <venv|virtualenv> <venv|.venv|.env|env> in your root directory and to activate it manually call activatevenv (also when you cd back into your project folder it will automatically activate it).
need to deactivate it when cd outside