Last active
July 4, 2016 21:33
-
-
Save libcrack/cc901a853793bf26906c2bc8224767a5 to your computer and use it in GitHub Desktop.
Python virtual environment bash helper
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
| #!/usr/bin/env bash | |
| # 28/05/2016 16:24:27 | |
| # [email protected] | |
| VENV="venv" | |
| V=2 | |
| [[ -n "${1}" ]] && V="${1}" | |
| [[ "$BASH_SOURCE" == "${0}" ]] && { | |
| myself="$(readlink -m ${0#-*})" | |
| echo "Usage: . ${myself}" > /dev/stderr | |
| exit 1 | |
| } || { | |
| [[ -d "${VENV}" ]] || { | |
| echo ">> Creating virtual environment at \"${VENV}\"" | |
| "virtualenv${V}" -p "/usr/bin/python${V}" "${VENV}" | |
| } | |
| echo ">> Entering virtual environment \"${VENV}\"" > /dev/stdout | |
| source "${VENV}/bin/activate" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment