📝 Update README with Python .venv auto-activation instructions for zsh
This commit is contained in:
@@ -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
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user