f8dffe5bce18ea4b6817e39f252f628a43b03712

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

Message

Merge pull request #198 from nogweii/smarter-precmd-hook

Improve the precmd hook

Diff

 1diff --git a/autoswitch_virtualenv.plugin.zsh b/autoswitch_virtualenv.plugin.zsh
 2index 4bc2c7f80be163bd512c6bd913dcacb58005b104..c08b9c1f84e981c184b6d7e2df84cd24b2324eb5 100644
 3--- a/autoswitch_virtualenv.plugin.zsh
 4+++ b/autoswitch_virtualenv.plugin.zsh
 5@@ -413,14 +413,15 @@ function disable_autoswitch_virtualenv() {
 6 # immediately removes itself from the zsh-hook.
 7 # This seems important for "instant prompt" zsh themes like powerlevel10k
 8 function _autoswitch_startup() {
 9-    if ! type "python" > /dev/null; then
10-        printf "WARNING: python binary not found on PATH.\n"
11+    local python_bin="${AUTOSWITCH_DEFAULT_PYTHON:-python}"
12+    if ! type "${python_bin}" > /dev/null; then
13+        printf "WARNING: python binary '${python_bin}' not found on PATH.\n"
14         printf "zsh-autoswitch-virtualenv plugin will be disabled.\n"
15     else
16-        add-zsh-hook -D precmd _autoswitch_startup
17         enable_autoswitch_virtualenv
18         check_venv
19     fi
20+    add-zsh-hook -D precmd _autoswitch_startup
21 }
22 
23 autoload -Uz add-zsh-hook