Diff
1diff --git a/CHANGELOG.rst b/CHANGELOG.rst
2index 8cab2a6ac8ebeb268b2f6b56fff8686f12589f3c..828b2fa5c42a9aae8df77c39776bfa9a0e344499 100644
3--- a/CHANGELOG.rst
4+++ b/CHANGELOG.rst
5@@ -1,6 +1,10 @@
6 Changelog
7 =========
8
9+1.8.2
10+-----
11+* local variables will no longer sneak into shell environment variables (Thanks @rnc)
12+
13 1.8.1
14 -----
15 * Fixes a regression in Pipenv integration
16diff --git a/README.rst b/README.rst
17index 161308c643b9678422cc991c31b28db75181ab85..1338890d164415bb20c2f8053a91d6808e730c94 100644
18--- a/README.rst
19+++ b/README.rst
20@@ -84,13 +84,20 @@ is the directory with custom plugins of oh-my-zsh `(read more) <https://github.c
21
22 git clone "https://github.com/MichaelAquilina/zsh-autoswitch-virtualenv.git" "$ZSH_CUSTOM/plugins/autoswitch_virtualenv"
23
24-
25 Then add this line to your ``.zshrc``
26
27 ::
28
29 plugins=(autoswitch_virtualenv $plugins)
30
31+**Manual Installation**
32+
33+Source the plugin shell script in your `~/.zshrc` profile. For example
34+
35+::
36+
37+ source $HOME/zsh-autoswitch-virtualenv/autoswitch_virtualenv.plugin.zsh
38+
39
40 Pipenv Integration
41 ------------------
42diff --git a/autoswitch_virtualenv.plugin.zsh b/autoswitch_virtualenv.plugin.zsh
43index 4aabc5d40c7683d2f5f3b46ff879779e2e6438f6..1a339e909af1a4bac59ceb2ce1a256caa79d8153 100644
44--- a/autoswitch_virtualenv.plugin.zsh
45+++ b/autoswitch_virtualenv.plugin.zsh
46@@ -1,4 +1,4 @@
47-export AUTOSWITCH_VERSION='1.8.1'
48+export AUTOSWITCH_VERSION='1.8.2'
49
50 RED="\e[31m"
51 GREEN="\e[32m"
52@@ -38,11 +38,11 @@ function _python_version() {
53
54
55 function _maybeworkon() {
56- venv_dir="$1"
57- venv_type="$2"
58- venv_name="$(basename $venv_dir)"
59+ local venv_dir="$1"
60+ local venv_type="$2"
61+ local venv_name="$(basename $venv_dir)"
62
63- DEFAULT_MESSAGE_FORMAT="Switching %venv_type: ${BOLD}${PURPLE}%venv_name${NORMAL} ${GREEN}[๐%py_version]${NORMAL}"
64+ local DEFAULT_MESSAGE_FORMAT="Switching %venv_type: ${BOLD}${PURPLE}%venv_name${NORMAL} ${GREEN}[๐%py_version]${NORMAL}"
65 if [[ "$LANG" != *".UTF-8" ]]; then
66 # Remove multibyte characters if the terminal does not support utf-8
67 DEFAULT_MESSAGE_FORMAT="${DEFAULT_MESSAGE_FORMAT/๐/}"
68@@ -57,9 +57,8 @@ function _maybeworkon() {
69 fi
70
71 if [ -z "$AUTOSWITCH_SILENT" ]; then
72- py_version="$(_python_version "$venv_dir/bin/python")"
73-
74- message="${AUTOSWITCH_MESSAGE_FORMAT:-"$DEFAULT_MESSAGE_FORMAT"}"
75+ local py_version="$(_python_version "$venv_dir/bin/python")"
76+ local message="${AUTOSWITCH_MESSAGE_FORMAT:-"$DEFAULT_MESSAGE_FORMAT"}"
77 message="${message//\%venv_type/$venv_type}"
78 message="${message//\%venv_name/$venv_name}"
79 message="${message//\%py_version/$py_version}"
80@@ -81,7 +80,8 @@ function _check_venv_path()
81 printf "${check_dir}/.venv"
82 return
83 else
84- if [ "$check_dir" = "/" ]; then
85+ # Abort search at file system root or HOME directory (latter is a perfomance optimisation).
86+ if [[ "$check_dir" = "/" || "$check_dir" = "$HOME" ]]; then
87 return
88 fi
89 _check_venv_path "$(dirname "$check_dir")"
90@@ -92,10 +92,10 @@ function _check_venv_path()
91 # Automatically switch virtualenv when .venv file detected
92 function check_venv()
93 {
94- SWITCH_TO=""
95+ local SWITCH_TO=""
96
97 # Get the .venv file, scanning parent directories
98- venv_path=$(_check_venv_path "$PWD")
99+ local venv_path=$(_check_venv_path "$PWD")
100 if [[ -n "$venv_path" ]]; then
101
102 stat --version &> /dev/null
103@@ -150,12 +150,11 @@ function _default_venv()
104 function rmvenv()
105 {
106 if [[ -f ".venv" ]]; then
107-
108- venv_name="$(<.venv)"
109+ local venv_name="$(<.venv)"
110
111 # detect if we need to switch virtualenv first
112 if [[ -n "$VIRTUAL_ENV" ]]; then
113- current_venv="$(basename $VIRTUAL_ENV)"
114+ local current_venv="$(basename $VIRTUAL_ENV)"
115 if [[ "$current_venv" = "$venv_name" ]]; then
116 _default_venv
117 fi
118@@ -176,7 +175,7 @@ function mkvenv()
119 if [[ -f ".venv" ]]; then
120 printf ".venv file already exists. If this is a mistake use the rmvenv command\n"
121 else
122- venv_name="$(basename $PWD)"
123+ local venv_name="$(basename $PWD)"
124
125 printf "Creating ${PURPLE}%s${NONE} virtualenv\n" "$venv_name"
126