A plugin for zsh to auto activate virtual environment. Applicable to uv, poetry.
It will check current path if exist .venvor venv folder. Determine whether to activate the virtual environment based on this folder.
- For oh-my-zsh:
git clone https://github.com/lxp731/auto-venv.git "$ZSH_CUSTOM/plugins/auto-venv"Then add this line to your .zshrc. Make sure it is before the line source $ZSH/oh-my-zsh.sh.
plugins=(
...
auto-venv
)- For bash:
wget https://raw.githubusercontent.com/lxp731/auto-venv/refs/heads/main/auto-venv.bash -O ~/.auto-venv.bashThen add this line to your .bashrc, and source it.
echo "" >> ~/.bashrc && \
echo "### auto-activate python virtual environment" >> ~/.bashrc && \
echo "source ~/.auto-venv.bash" >> ~/.bashrc && \
source ~/.bashrc