aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBaptiste Darthenay <baptiste@darthenay.fr>2016-12-28 11:35:56 +0100
committerBaptiste Darthenay <baptiste@darthenay.fr>2016-12-28 11:35:56 +0100
commitdbbc7dc2950d6b565488864ee8ebf53a73d6e8eb (patch)
tree55b3bf29f027bb7f3ab12dd0bd2ec2eac79ee94b
parentef80fa0bec2df62c2ea5469123b4ad794c7c9306 (diff)
Jumps to project directory if exists.
-rw-r--r--README.md5
-rwxr-xr-xvenvworkon.sh5
2 files changed, 10 insertions, 0 deletions
diff --git a/README.md b/README.md
index 3376c4b..acbec3b 100644
--- a/README.md
+++ b/README.md
@@ -28,6 +28,11 @@ If the file `$HOME/.venvs/<venv>/postactivate.sh` exists, it is
automatically sourced after the venv is activated. This is useful
to export environment variable such as `DJANGO_SETTINGS_MODULE`.
+## Project directory
+If `PROJECT_HOME` is set (e.g. `$HOME/Projects`) and there is
+a project folder which match the environment name, venvworkon
+change the current working directory to the project directory.
+
## Why bother using this
`virtualenvwrapper` is certainly much more feature-packed and
useful than this. But this wrapper is handy for development and
diff --git a/venvworkon.sh b/venvworkon.sh
index f6ac4ef..960048b 100755
--- a/venvworkon.sh
+++ b/venvworkon.sh
@@ -26,6 +26,11 @@ workon() {
source "$envdir/bin/activate"
+ if [ -d "$PROJECT_HOME/$envname" ]
+ then
+ cd "$PROJECT_HOME/$envname"
+ fi
+
if [ -e "$envdir/postactivate.sh" ]
then
source "$envdir/postactivate.sh"