37a89768666dab1ec02c5f664c271d78a1b2c040
- Author
- Michael Aquilina <michaelaquilina@gmail.com>
- Committer
- Michael Aquilina <michaelaquilina@gmail.com>
- Date
Message
Add enable and disable functions
Diff
1diff --git a/README.rst b/README.rst
2index db279e25a9bca1d50791ee529a1429d4c8b45850..9b093554dc4aecb236f86d3c7aa1520da05be2b5 100644
3--- a/README.rst
4+++ b/README.rst
5@@ -163,6 +163,16 @@ This will delete the virtual environment in ``.venv`` and remove the
6 $ rmvenv
7 No .venv file in the current directory!
8
9+disable_autoswitch_virtualenv
10+'''''''''''''''''''''''''''''
11+
12+Temporarily disables autoswitching of virtualenvs when moving between
13+directories.
14+
15+enable_autoswitch_virtualenv
16+''''''''''''''''''''''''''''
17+
18+Re-enable autoswitching of virtualenvs (if it was previously disabled).
19
20 Customising Messages
21 --------------------
22diff --git a/autoswitch_virtualenv.plugin.zsh b/autoswitch_virtualenv.plugin.zsh
23index 66803ab45e5cd3668f0460ad1bdc80721933d202..42becc09991e76ab9e7174208f5468c7cbd4185a 100644
24--- a/autoswitch_virtualenv.plugin.zsh
25+++ b/autoswitch_virtualenv.plugin.zsh
26@@ -197,10 +197,19 @@ function install_requirements() {
27 }
28
29
30-if [[ -z "$DISABLE_AUTOSWITCH_VENV" ]]; then
31+function enable_autoswitch_virtualenv() {
32 autoload -Uz add-zsh-hook
33- add-zsh-hook -D chpwd check_venv
34+ disable_autoswitch_virtualenv
35 add-zsh-hook chpwd check_venv
36+}
37
38+
39+function disable_autoswitch_virtualenv() {
40+ add-zsh-hook -D chpwd check_venv
41+}
42+
43+
44+if [[ -z "$DISABLE_AUTOSWITCH_VENV" ]]; then
45+ enable_autoswitch_virtualenv
46 check_venv
47 fi