diff --git a/README.rst b/README.rst index 3182727..c01cb9e 100644 --- a/README.rst +++ b/README.rst @@ -315,6 +315,22 @@ By default `mkvenv` will install setup.py via pip in editable (i.e. development) and `here `__ for further information. To change this set ``AUTOSWITCH_PIPINSTALL`` to ``FULL``. +**Disabling the suggestion to run mkvenv** + +By default, this plugin prints a suggestion to run `mkvenv` when it detects a +supported project without an initialized virtual environment: + +:: + + Python $venv_type project detected. Run mkvenv to setup autoswitching + +This can be silenced by setting the environment variable +``AUTOSWITCH_HIDE_MKVENV_SUGGESTION``: + +:: + + export AUTOSWITCH_HIDE_MKVENV_SUGGESTION=1 + Security Warnings ----------------- diff --git a/autoswitch_virtualenv.plugin.zsh b/autoswitch_virtualenv.plugin.zsh index bbd2308..f9a4d5e 100644 --- a/autoswitch_virtualenv.plugin.zsh +++ b/autoswitch_virtualenv.plugin.zsh @@ -31,7 +31,7 @@ function _virtual_env_dir() { function _python_version() { local PYTHON_BIN="$1" - if [[ -f "$PYTHON_BIN" ]] then + if [[ -f "$PYTHON_BIN" ]]; then # For some reason python --version writes to stderr printf "%s" "$($PYTHON_BIN --version 2>&1)" else @@ -209,8 +209,10 @@ function check_venv() # If we still haven't got anywhere, fallback to defaults if [[ "$venv_type" != "unknown" ]]; then - printf "Python ${PURPLE}$venv_type${NORMAL} project detected. " - printf "Run ${PURPLE}mkvenv${NORMAL} to setup autoswitching\n" + if (( !AUTOSWITCH_HIDE_MKVENV_SUGGESTION )); then + printf "Python ${PURPLE}$venv_type${NORMAL} project detected. " + printf "Run ${PURPLE}mkvenv${NORMAL} to setup autoswitching\n" + fi fi _default_venv }