Prefix old PWD variable to prevent prezto from acting strangely
Diff
1diff --git a/autoswitch_virtualenv.plugin.zsh b/autoswitch_virtualenv.plugin.zsh
2index c615cbb9fd9562687e8d026590d4d04b01bad222..446f0583be077327911587fb1de01f0ca0206e36 100644
3--- a/autoswitch_virtualenv.plugin.zsh
4+++ b/autoswitch_virtualenv.plugin.zsh
5@@ -20,7 +20,7 @@ function _maybeworkon() {
6 workon "$1"
7 8 if [ -z "$AUTOSWITCH_SILENT" ]; then
9- # For some reason python --version writes to stderr
10+ # For some reason python --version writes to st derr
11 printf "[%s]\n" "$(python --version 2>&1)"
12 fi
13 fi
14@@ -47,8 +47,11 @@ function _check_venv_path()
15 # Automatically switch virtualenv when .venv file detected
16 function check_venv()
17 {
18- if [ "$PWD" != "$MYOLDPWD" ]; then
19- MYOLDPWD="$PWD"
20+ if [ "AS:$PWD" != "$MYOLDPWD" ]; then
21+ # Prefix PWD with "AS:" to signify this belongs to this plugin
22+ # this prevents the AUTONAMEDIRS in prezto from doing strange things
23+ # See https://github.com/MichaelAquilina/zsh-autoswitch-virtualenv/issues/19
24+ MYOLDPWD="AS:$PWD"
2526 SWITCH_TO=""
2728diff --git a/tests/test_check_venv.zunit b/tests/test_check_venv.zunit
29index d50458c5e3a62d6933c5c8bf95404763b1081b63..c312bd9ad0d4960849cd1e3af4648fb36728d57d 100644
30--- a/tests/test_check_venv.zunit
31+++ b/tests/test_check_venv.zunit
32@@ -44,7 +44,8 @@
3334 @test 'check_venv - does not change if MYOLDPWD=PWD' {
35 PWD="$TARGET"
36- MYOLDPWD="$TARGET"
37+ # Must be prefixed. See code for details
38+ MYOLDPWD="AS:$TARGET"
3940 echo "foobar" > "$TARGET/.venv"
41