mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-12-18 10:22:00 +00:00
94ea7b4516
* Test only for the presence of a .git directory in virtualenvwrapper Instead of using both $(git rev-parse --show-toplevel) and a check for a .git directory, use just the latter. As well as being redundant the former does not work quite so well when using multiple worktrees; each worktree will be treated as a separate project. * Unset ENV_NAME & deactivate if no virtualenv found This addresses #4603 without breaking current behaviour (where current behaviour is correct). When changing directories, if there is no environment matching ENV_NAME, ENV_NAME is emptied and deactivate called if there is a current environment active (based on CD_VIRTUAL_ENV). * Use path comparison not string comparison for paths This will solve part of issue #4255 where WORKON_HOME is defined with a trailing slash or not normalised in some way, as well as instances where symlinks are used, and any other instances where constructed paths don't exactly match even though they go to the same file. Co-authored-by: Robby Russell <robby@planetargon.com> |
||
---|---|---|
.. | ||
README.md | ||
virtualenvwrapper.plugin.zsh |
Virtualenvwrapper plugin
This plugin loads Python's virtualenvwrapper shell tools.
To use it, add virtualenvwrapper
to the plugins array in your zshrc file:
plugins=(... virtualenvwrapper)
Usage
The plugin allows to automatically activate virtualenvs on cd into git repositories with a matching name:
➜ github $ cd ansible
(ansible) ➜ ansible git:(devel) $ cd docs
(ansible) ➜ docs git:(devel) $ cd ..
(ansible) ➜ ansible git:(devel) $ cd ..
➜ github $
We can override this by having a .venv
file in the directory containing a differently named virtualenv:
➜ github $ cat ansible/.venv
myvirtualenv
➜ github $ cd ansible
(myvirtualenv) ➜ ansible git:(devel) $ cd ..
➜ github $
We can disable this behaviour by setting DISABLE_VENV_CD=1
before Oh My Zsh is sourced:
DISABLE_VENV_CD=1
plugins=(... virtualenvwrapper)
source $ZSH/oh-my-zsh.sh