aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBaptiste Darthenay <baptiste@darthenay.fr>2016-12-27 19:54:25 +0100
committerBaptiste Darthenay <baptiste@darthenay.fr>2016-12-27 20:19:33 +0100
commitb5775083a1fe12b3393789ad6b4ea67c67112558 (patch)
tree31d9722c22ca594d29b7421436cd2426ab8f252f
parente33cb3f849dc32e5c0f083ac5f1394dc792b32a1 (diff)
Using WORKON_HOME instead of envroot.
This improves compatibility with virtualenvwrapper.
-rw-r--r--README.md4
-rwxr-xr-xvenvworkon.sh13
2 files changed, 11 insertions, 6 deletions
diff --git a/README.md b/README.md
index 3ddcf66..fc74104 100644
--- a/README.md
+++ b/README.md
@@ -19,7 +19,9 @@ will be printed instead.
## Where venvs are created
When `workon` is called, venvs are created or loaded from the
-`$HOME/.venvs` folder.
+`$HOME/.venvs` folder by default.
+To change this behavior, set the `WORKON_HOME` environment
+variable before sourcing `venvworkon.sh`.
## Post-load script
If the file `$HOME/.venvs/<venv>/postload.sh` exists, it is
diff --git a/venvworkon.sh b/venvworkon.sh
index 1da01bd..adca644 100755
--- a/venvworkon.sh
+++ b/venvworkon.sh
@@ -1,20 +1,23 @@
workon() {
- envroot="$HOME/.venv"
+ if [ -z "$WORKON_HOME" ]
+ then
+ WORKON_HOME="$HOME/.venv"
+ fi
- if [ ! -e "$envroot" ]
+ if [ ! -e "$WORKON_HOME" ]
then
- mkdir -p "$envroot"
+ mkdir -p "$WORKON_HOME"
fi
if [ "$#" -lt "1" ]
then
- ls "$envroot"
+ ls "$WORKON_HOME"
return
fi
envname=$1
- envdir="$envroot/$envname"
+ envdir="$WORKON_HOME/$envname"
if [ ! -e "$envdir" ]
then