Automatically activate venv when you enter a project folder.
-
Add the following to your
.zshrc:antigen bundle k-sriram/zsh-auto-venv
-
Start a new terminal session.
-
Clone this repository into
$ZSH_CUSTOM/plugins(by default~/.oh-my-zsh/custom/plugins)git clone https://github.com/k-sriram/zsh-auto-venv ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-auto-venv --depth=1 -
Add the plugin to the list of plugins for Oh My Zsh to load (inside
~/.zshrc):plugins=( ... zsh-auto-venv )
-
Start a new terminal session.
-
Clone this repository somewhere on your machine.
git clone https://github.com/k-sriram/zsh-auto-venv ~/.zsh/zsh-auto-venv -
Add the following to your
.zshrc:source ~/.zsh/zsh-auto-venv/zsh-auto-venv.zsh
-
Start a new terminal session.
zsh-auto-venv can be configured using environment variables.
Disable automatic activation by setting AUTOVENV_DISABLE to any value. Most of the automatic features are disabled when the user manually activates a venv.
For the purposes of auto-activation only venvs with the name defined by AUTOVENV_DIR are looked for. It not set a default value of .venv is used.
This plugin automatically deactivates venv as you leave the directory that they are situated in or any its children. This only auto-deactivates venvs that were activated automatically by entering the directory. If you want to disable this behaviour set AUTOVENV_NOAUTODEACTIVATE.
With an already auto-activated venv if you move into a new sub-directory that also has an auto-activatable venv, this new venv will be activated. To disable this behaviour set AUTOVENV_DONT_ACTIVATE_SUBDIR_VENV
This plugin provides a function autovenv::activate. If you intend to use it, it is advised alias it to something more usable.
alias venv='autovenv::activate'This function searches for venvs. It first looks in the current directory / path passed as argument, then at the root of a git repository if inside one, then in the user's home directory. This function is not just limited to venvs of name AUTOENV_DIR, it looks for them by checking if they have a ./bin/activate file.