📝 Update README with Python .venv auto-activation instructions for zsh

This commit is contained in:
2026-04-19 15:34:07 +08:00
parent e1c1783e7c
commit a5c0c12122
+23
View File
@@ -17,3 +17,26 @@ uv run https://script.hatter.ink/@0/httpstat.py https://hatter.ink/
> https://github.com/reorx/httpstat
<br>
Auto activate Python `.venv` in zsh, edit `~/.zshrc`:
```shell
_venv_auto_activate() {
if [ -d ".venv" ] && [ -f ".venv/bin/activate" ]; then
if [ -z "$VIRTUAL_ENV" ]; then
source .venv/bin/activate
elif [[ "$VIRTUAL_ENV" != *".venv" ]]; then
deactivate
source .venv/bin/activate
fi
elif [ -n "$VIRTUAL_ENV" ]; then
deactivate
fi
}
autoload -U add-zsh-hook
add-zsh-hook chpwd _venv_auto_activate
_venv_auto_activate
```