X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=plugins%2Fvirtualenv%2Fvirtualenv.zshrc;h=43614aff0d28daddf263c2228eba65d334b08c19;hb=ffb6d0b2331ad5dfbdeb4eb7d68336f339289774;hp=436c667f253f82f27ace9cdab7cac124454de7c0;hpb=aaed9b4e35c28dd244fa026872f6c19d125d8cae;p=ax-zsh.git diff --git a/plugins/virtualenv/virtualenv.zshrc b/plugins/virtualenv/virtualenv.zshrc index 436c667..43614af 100644 --- a/plugins/virtualenv/virtualenv.zshrc +++ b/plugins/virtualenv/virtualenv.zshrc @@ -5,6 +5,18 @@ [[ -z "$AXZSH_PLUGIN_CHECK" ]] || return 92 function activate() { + local d r + + # Make sure no "virtual environment" is already active! + if [[ -n "$VIRTUAL_ENV" ]]; then + echo "Oops, looks like a virtual environment is already active!" >&2 + return 1 + fi + + if [[ -r Pipfile ]]; then + pipenv run "$SHELL"; r=$? + return $r + fi for d ( ./bin ./env/bin @@ -20,6 +32,11 @@ function activate() { echo "Failed to read script \"$script\"!" >&2 return 1 done + echo "No virtual environment found!" >&2 return 1 } + +if [[ -n "$PIPENV_ACTIVE" ]]; then + alias deactivate=exit +fi