decc342b28e1b936ba3c3c99bae0679d0fa56add

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

Message

Prepend functions not meant to be used by users with _

Diff

 1diff --git a/autoswitch_virtualenv.plugin.zsh b/autoswitch_virtualenv.plugin.zsh
 2index 2eeeb9fbbdee77e4a8d954186e4a6bd124e785e8..1b349b9868ab43aca54b28b7e504187aa7bf148d 100644
 3--- a/autoswitch_virtualenv.plugin.zsh
 4+++ b/autoswitch_virtualenv.plugin.zsh
 5@@ -1,8 +1,8 @@
 6 function precmd() {
 7-  check_venv
 8+  _check_venv
 9 }
10 
11-function maybeworkon() {
12+function _maybeworkon() {
13   if [[ -z "$VIRTUAL_ENV" || "$1" != "$(basename $VIRTUAL_ENV)" ]]; then
14      if [ -z "$AUTOSWITCH_SILENT" ]; then
15         printf "Switching virtualenv: %s  " $1
16@@ -18,7 +18,7 @@ function maybeworkon() {
17 }
18 
19 # Gives the path to the nearest parent .venv file or nothing if it gets to root
20-function check_venv_path()
21+function _check_venv_path()
22 {
23     local check_dir=$1
24 
25@@ -29,20 +29,20 @@ function check_venv_path()
26         if [ "$check_dir" = "/" ]; then
27             return
28         fi
29-        check_venv_path "$(dirname "$check_dir")"
30+        _check_venv_path "$(dirname "$check_dir")"
31     fi
32 }
33 
34 
35 # Automatically switch virtualenv when .venv file detected
36-function check_venv()
37+function _check_venv()
38 {
39     if [ "$PWD" != "$MYOLDPWD" ]; then
40         MYOLDPWD="$PWD"
41 
42         SWITCH_TO=""
43 
44-        venv_path=$(check_venv_path "$PWD")
45+        venv_path=$(_check_venv_path "$PWD")
46         if [[ -n "$venv_path" ]]; then
47           file_owner="$(stat -c %u "$venv_path")"
48           file_permissions="$(stat -c %a "$venv_path")"
49@@ -64,19 +64,19 @@ function check_venv()
50         fi
51 
52         if [[ -n "$SWITCH_TO" ]]; then
53-          maybeworkon "$SWITCH_TO"
54+          _maybeworkon "$SWITCH_TO"
55         elif [[ "$PWD" != "$AUTOSWITCH_PROJECT/"* ]]; then
56-          default_venv
57+          _default_venv
58           AUTOSWITCH_PROJECT=""
59         fi
60     fi
61 }
62 
63 # Switch to the default virtual environment
64-function default_venv()
65+function _default_venv()
66 {
67   if [[ -n "$AUTOSWITCH_DEFAULTENV" ]]; then
68-     maybeworkon "$AUTOSWITCH_DEFAULTENV"
69+     _maybeworkon "$AUTOSWITCH_DEFAULTENV"
70   elif [[ -n "$VIRTUAL_ENV" ]]; then
71      deactivate
72   fi
73@@ -90,7 +90,7 @@ function rmvenv()
74     venv_name="$(<.venv)"
75     current_venv="$(basename $VIRTUAL_ENV)"
76     if [[ "$current_venv" = "$venv_name" ]]; then
77-      default_venv
78+      _default_venv
79     fi
80     rmvirtualenv "$venv_name"
81     rm ".venv"