Automatically activate virtual environments in fish. Based on gists by bastibe and tommyip.
- Automatically activates Python virtual environments when entering a directory containing a venv
- Automatically deactivates virtual environments when leaving the directory
- Safely handles virtual environment inheritance in new shell sessions
- Prevents shell exits during activation/deactivation
- Works with common virtual environment directory names:
env,.env,venv,.venv - Supports git repositories by detecting the repository root
Using fisher (Recommended):
Run
fisher install nakulj/auto-venvCopy conf.d/venv.fish into your conf.d directory (usually ~/.config/fish/conf.d)
The plugin uses fish shell events and directory monitoring to:
- Detect when you change directories and automatically activate/deactivate virtual environments
- Handle virtual environment inheritance in new shell sessions safely
- Implement safe activation/deactivation that won't cause the shell to exit
The plugin looks for virtual environments in the following directories:
env/.env/venv/.venv/
If you're in a git repository, it will look for these directories at the repository root.