1. Create a function in the .zshrc
# ~/.zshrc
activate() {
if [ -d “.venv” ]; then
source .venv/bin/activate
else
: # ignore if no .venv
fi
}
activate() {
if [ -d “.venv” ]; then
source .venv/bin/activate
else
: # ignore if no .venv
fi
}
2. Set iTerm to call this function on a new tap
iTerm2: Preferences -> Profiles -> Command: Login Shell -> Send text at start: “activate”