aboutsummaryrefslogtreecommitdiff
path: root/venvworkon.sh
diff options
context:
space:
mode:
authorEtenil <dev@etenil.net>2017-10-09 10:00:11 +0100
committerEtenil <dev@etenil.net>2017-10-09 10:00:11 +0100
commitd5268b858d9ac9377480248519a5749964236399 (patch)
treeaed01d8798cb3121308405459d4656de7d76a99a /venvworkon.sh
parent7818577867f0a266de6e779c268abe3c5f13697d (diff)
Added ability to configure the python version.
Diffstat (limited to 'venvworkon.sh')
-rwxr-xr-xvenvworkon.sh13
1 files changed, 11 insertions, 2 deletions
diff --git a/venvworkon.sh b/venvworkon.sh
index d714936..ad0090e 100755
--- a/venvworkon.sh
+++ b/venvworkon.sh
@@ -12,20 +12,29 @@ workon() {
# Quit if there is no arguments, while showing available venvs
if [ "$#" -lt "1" ]; then
- ls "$WORKON_HOME"
+ echo "Usage: workon ENV_NAME PYTHON_VERSION"
+ echo "Available envs:"
+ ls "$WORKON_HOME"
return
fi
envdir="$WORKON_HOME/$1"
+ python_version="3"
if [ "$1" == "." ]; then
target=$(basename `pwd`)
envdir="$WORKON_HOME/$target"
fi
+ if [ "$#" -gt "1" ]; then
+ python_version=$2
+ fi
+
+ python_exec="python$python_version"
+
# Creates virtual env if doesn't exists
if [ ! -e "$envdir" ]; then
- python3 -m venv $envdir
+ $python_exec -m venv $envdir
echo "Virtual env created in $envdir"
fi