Question

I have a one-line entry in my virtualenv postactivate script which notifies my of which virtualenv I'm in:

export PS1="\[\033[40;1;36m\](`basename $VIRTUAL_ENV`)\[\033[00m\]\[\033[01;34m\] \W\[\033[00m\] \$ "

I want to add a line which will also change into the directory of my project when I issue the workon command. This is only for me really, so I am happy to issue the command workon myproject and use myproject as the only variable and then change to /path/to/projects/myproject. This will work as all my projects are in the same directory. To demonstrate:

cd ~/projects/django-projects/$1

Would work, but of course the command variable is actually post_activate. Can I easily grab the string from the command line and pass it to this script?

Any help much appreciated.

Was it helpful?

Solution

This is how I did it, hough I think there are various solutions:

dir=${VIRTUAL_ENV:17}; cd ~/projects/django-projects/$dir
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top