Created
January 22, 2014 10:54
-
-
Save paveldedik/8556845 to your computer and use it in GitHub Desktop.
Command which activates or creates a virtual environment. It's a modification of the original command which doesn't work for me properly.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # The use_env call below is a reusable command to activate/create a new Python | |
| # virtualenv, requiring only a single declarative line of code in your .env files. | |
| # It only performs an action if the requested virtualenv is not the current one. | |
| use_env() { | |
| typeset venv | |
| venv="$1" | |
| if [[ "${VIRTUAL_ENV##*/}" != "$venv" ]]; then | |
| if workon | grep -q "$venv"; then | |
| workon "$venv" | |
| else | |
| echo -n "Create virtualenv \"$venv\" now? (Y/n) " | |
| read answer | |
| if [[ "$answer" != "n" ]]; then | |
| mkvirtualenv "$venv" | |
| fi | |
| fi | |
| fi | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment