autoenv.plugin.zsh 614 B

12345678910111213141516171819
  1. # The use_env call below is a reusable command to activate/create a new Python
  2. # virtualenv, requiring only a single declarative line of code in your .env files.
  3. # It only performs an action if the requested virtualenv is not the current one.
  4. use_env() {
  5. typeset venv
  6. venv="$1"
  7. if [[ "${VIRTUAL_ENV:t}" != "$venv" ]]; then
  8. if workon | grep -q "$venv"; then
  9. workon "$venv"
  10. else
  11. echo -n "Create virtualenv $venv now? (Yn) "
  12. read answer
  13. if [[ "$answer" == "Y" ]]; then
  14. mkvirtualenv "$venv"
  15. fi
  16. fi
  17. fi
  18. }