Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to hide suggestion to run mkvenv #167

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,22 @@ By default `mkvenv` will install setup.py via pip in editable (i.e. development)
and `here <https://pip.pypa.io/en/stable/reference/pip_install/#editable-installs/>`__ 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
-----------------

Expand Down
8 changes: 5 additions & 3 deletions autoswitch_virtualenv.plugin.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down