2c7b2dcdd37cc824064834034df957436a138dc1
- Author
- Michael Aquilina <michaelaquilina@gmail.com>
- Committer
- Michael Aquilina <michaelaquilina@gmail.com>
- Date
Message
Only check for python on precmd
This allows plugins like pyenv that load python in PATH later
to work correctly
Diff
1diff --git a/autoswitch_virtualenv.plugin.zsh b/autoswitch_virtualenv.plugin.zsh
2index 436f7b0b211501fa1b17ccf5e0965f6e61712009..94338ad5cc6306d0224019056fb91b2d20d5485f 100644
3--- a/autoswitch_virtualenv.plugin.zsh
4+++ b/autoswitch_virtualenv.plugin.zsh
5@@ -413,15 +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- add-zsh-hook -D precmd _autoswitch_startup
10- enable_autoswitch_virtualenv
11- check_venv
12+ if ! type "python" > /dev/null; then
13+ printf "WARNING: python binary 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 }
21
22-if ! type "${AUTOSWITCH_DEFAULT_PYTHON:-python}" > /dev/null; then
23- printf "WARNING: python binary not found on PATH.\n"
24- printf "zsh-autoswitch-virtualenv plugin will be disabled.\n"
25-else
26- autoload -Uz add-zsh-hook
27- add-zsh-hook precmd _autoswitch_startup
28-fi
29+autoload -Uz add-zsh-hook
30+add-zsh-hook precmd _autoswitch_startup