804c1bb18ff9a1b1df506ba0f92d3b9e54d2778b
- Author
- Michael Aquilina <michaelaquilina@gmail.com>
- Committer
- Michael Aquilina <michaelaquilina@gmail.com>
- Date
Message
Diff
This diff is truncated to protect this page.
1diff --git a/README.md b/README.md
2index 340aa37849f24aa171ded170f1c268ac591a75ad..3372aa7e3bec7dc220891c8cd3ec0eb17373455b 100644
3--- a/README.md
4+++ b/README.md
5@@ -1,24 +1,27 @@
6+:tada: Pull Requests for fixes or improvements are welcome! :tada:
7+
8 Autoswitch Python Virtualenv
9 ============================
10
11-*zsh-autoswitch-virtualenv* is a simple ZSH plugin that switches python virtualenvs automatically as you move between directories.
12+*zsh-autoswitch-virtualenv* is a simple ZSH plugin that switches python virtualenvs automatically as
13+you move between directories.
14
15-Simply create a `.venv` file with the name of the virtualenv you want to automatically switch to
16-when you move into a directory. Moving out of the directory will automatically switch back to the
17-default python virtual environment - set by the `AUTOSWITCH_DEFAULTENV` environment variable. If
18-`AUTOSWITCH_DEFAULTENV` has not been set, then moving to a directory without a `.venv` file will
19-deactivate any currently active virtualenv.
20+This plugin simply allows you to create a virtual environment with the same name as the current
21+directory. However that virtualenv will now be automatically activated when you enter the same
22+directory again and deactivate it when you move outside!
23
24-NOTE: The virutalenv you specify in `.venv` must already exist. I personally use the following function (found in my `~/.zshrc`) to make this process convenient:
25-```
26-function mkvenv() {
27- venv_name="$(basename $PWD)"
28- echo "$venv_name" > ".venv"
29- mkvirtualenv "$venv_name" $@
30-}
31-```
32+You do this by simply calling the `mkvenv` command in the directory you wish to setup a virtual
33+environment. After that command is completed, everything is setup and you are good to go!
34
35-:tada: Pull Requests for fixes or improvements are welcome! :tada:
36+Moving out of the directory will automatically deactivate the virtual environment. However you can
37+also switch back to a default python virtual environment by setting the `AUTOSWITCH_DEFAULTENV`
38+environment variable. If `AUTOSWITCH_DEFAULTENV` has not been set, then moving to a directory
39+without a `.venv` file will deactivate any currently active virtualenv.
40+
41+Internally this plugin simply worksby creating a file named `.venv` which contains the name of the
42+virtual environment created (which is the same name as the current directory but can be edited if
43+needed). There is then a precommand hook that looks for a `.venv` file and switches to the name
44+specified if one is found.
45
46 Requirements
47 ------------
48@@ -33,8 +36,8 @@ Mac OSX users can install `virtualenvwrapper` with brew:
49
50 `brew install virtualenvwrapper`
51
52-Installing with Antigen
53------------------------
54+Installing with Antigen/Zgen
55+----------------------------
56
57 Installing with [Antigen](https://github.com/zsh-users/antigen) is super easy! Just add the following line to your `.zshrc`:
58
59@@ -42,35 +45,31 @@ Installing with [Antigen](https://github.com/zsh-users/antigen) is super easy! J
60 antigen bundle MichaelAquilina/zsh-autoswitch-virtualenv
61 ```
62
63-Installing with Zgen
64---------------------
65-
66 Installing with [Zgen](https://github.com/tarjoilija/zgen) is also easy! Add the following line to your `.zshrc`:
67
68-```zgen load MichaelAquilina/zsh-autoswitch-virtualenv```
69-
70-where you're making your other `zgen load` calls.
71-
72-Setting a default virtualenv
73-----------------------------
74-
75-If you want to set a default virtual environment then you can also export `AUTOSWITCH_DEFAULTENV` in
76-your `.zshrc` file.
77-
78 ```
79-export AUTOSWITCH_DEFAULTENV="mydefaultenv"
80-antigen bundle MichaelAquilina/zsh-autoswitch-virtualenv
81+zgen load MichaelAquilina/zsh-autoswitch-virtualenv
82 ```
83
84-Example:
85+Commands
86 --------
87
88-Setup a new project with virtualenv autoswitching
89+Setup a new project with virtualenv autoswitching using the `mkvenv` helper command.
90 ```
91 $ cd my-python-project
92-$ mkvirtualenv my-python-project
93-$ echo "my-python-project" > .venv
94+$ mkvenv
95+Using real prefix '/usr'
96+New python executable in /home/michael/.virtualenvs/my-python-project/bin/python2
97+Also creating executable in /home/michael/.virtualenvs/my-python-project/bin/python
98+Installing setuptools, pip, wheel...done.
99+Found a requirements.txt. Install? (y/N): y
100+Collecting requests (from -r requirements.txt (line 1))
101+ Using cached requests-2.11.1-py2.py3-none-any.whl
102+Installing collected packages: requests
103+Successfully installed requests-2.11.1
104 ```