- oh-my-zsh plugin
- Automaticall activate and deactivate Python Virtual Environment when you change directory
- Installed Virtual Environment directory name must be one of
venv,env,.venv,.env
git clone https://github.com/peppy0510/zsh-venv-auto.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-venv-auto- Add
zsh-venv-autoto~/.zshrcpluginssection.
vim ~/.zshrczsh-venv-auto- Add the initial activation to the end of
~/.zshrc, below everyPATHexport.
(( $+functions[auto_activate_venv] )) && auto_activate_venvThe plugin deliberately does not activate on load. A venv's activate snapshots PATH
into _OLD_VIRTUAL_PATH, and deactivate restores that snapshot verbatim. oh-my-zsh sources
plugins near the top of ~/.zshrc, so activating at load time snapshots a PATH that is
missing everything set further down — nvm's node, JAVA_HOME, CUDA. The first cd out of
that venv then restores the half-built snapshot and those tools silently vanish from PATH.
Calling auto_activate_venv at the very end instead makes the snapshot complete.