7f2898d38980d4fdb26cd278f7ebf776666bcb13

Author
Michael Aquilina <michaelaquilina@gmail.com>
Committer
Michael Aquilina <michaelaquilina@gmail.com>
Date

Message

Change _check_venv to check_venv and add instructions in README
explaining how to run autoswitch on your initial directory

Diff

 1diff --git a/README.rst b/README.rst
 2index 6c81449af0895c5b078b848f1ccaa5a99f30cb31..448dfe6fea160957c73d9b4f88f1ab7ea733a848 100644
 3--- a/README.rst
 4+++ b/README.rst
 5@@ -52,6 +52,27 @@ setup. This should work:
 6 Make sure this is put *before* your package manager loading code (i.e. the
 7 line of code discussed in the section that follows).
 8 
 9+If you wish autoswitch to detect the initial directory when the terminal
10+is starting up, then add the following line of code to you ``.zshrc`` file after
11+loading your plugin manager.
12+
13+::
14+
15+    check_venv
16+
17+In combination, your ``.zshrc`` file should look something like this (if you
18+are using zplug)
19+
20+::
21+
22+    zplug "MichaelAquilina/zsh-autoswitch-virtualenv"
23+    source =virtualenvwrapper.sh
24+
25+    zplug load
26+
27+    # Check initial directory for any .venv file
28+    check_venv
29+
30 Installing with ZSH Package Managers
31 ------------------------------------
32 
33@@ -62,19 +83,19 @@ ZPlug_
34 
35 ::
36 
37-    zplug MichaelAquilina/zsh-autoswitch-virtualenv
38+    zplug "MichaelAquilina/zsh-autoswitch-virtualenv"
39 
40 Antigen_
41 
42 ::
43 
44-    antigen bundle MichaelAquilina/zsh-autoswitch-virtualenv
45+    antigen bundle "MichaelAquilina/zsh-autoswitch-virtualenv"
46 
47 Zgen_
48 
49 ::
50 
51-    zgen load MichaelAquilina/zsh-autoswitch-virtualenv
52+    zgen load "MichaelAquilina/zsh-autoswitch-virtualenv"
53 
54 Commands
55 --------
56diff --git a/autoswitch_virtualenv.plugin.zsh b/autoswitch_virtualenv.plugin.zsh
57index f3f9656cd0ff1cf2ed11a3e0ea4eceabed231f5e..7d5ced818c263722f53b45e9a1e248e57b73adfc 100644
58--- a/autoswitch_virtualenv.plugin.zsh
59+++ b/autoswitch_virtualenv.plugin.zsh
60@@ -32,7 +32,7 @@ function _check_venv_path()
61 
62 
63 # Automatically switch virtualenv when .venv file detected
64-function _check_venv()
65+function check_venv()
66 {
67     if [ "$PWD" != "$MYOLDPWD" ]; then
68         MYOLDPWD="$PWD"
69@@ -130,5 +130,5 @@ function mkvenv()
70 }
71 
72 autoload -Uz add-zsh-hook
73-add-zsh-hook -D chpwd _check_venv
74-add-zsh-hook chpwd _check_venv
75+add-zsh-hook -D chpwd check_venv
76+add-zsh-hook chpwd check_venv
77diff --git a/tests/test_check_venv_path.zunit b/tests/test_check_venv_path.zunit
78index 04a8f56ff67518045a2f333f82753207d8c7de5a..1665d3850ae8c581cddd588fa0c7b9b8eff6002a 100644
79--- a/tests/test_check_venv_path.zunit
80+++ b/tests/test_check_venv_path.zunit
81@@ -12,7 +12,7 @@
82 }
83 
84 @test 'chpwd functions are loaded' {
85-    assert '_check_venv' in $chpwd_functions
86+    assert 'check_venv' in $chpwd_functions
87 }
88 
89 @test '_check_venv_path with non-existent path' {