Git Bash: how to change directory when activating virtual environment

Created virtualenvs in Python 3.6.1 using virtualenvwrapper using git bash terminal mingw64, Win7.

How can I automatically change my working directory to a different location when activating a specific virtual environment?

Example: When I start workon temp_env

, I want the working directory to be changed as if I had just started cd "/c/Users/me/Desktop/temp_env"

.

+3


source to share


1 answer


I need a setting where the working directory will automatically change to a location specific to a particular virtual environment.

  • After installation, virtualenvwrapper

    I added the following lines to the ~/.bashrc

    behind docs

    export WORKON_HOME=$HOME/.virtualenvs
    source virtualenvwrapper.sh
    
          

  • Then I created a new virtual env: mkvirtualenv temp_env

  • Inside the directory, $HOME/.virtualenvs/temp_env

    I added a line to the postactivate

    script (which was created with the virtual env) to change the working directory

     cd "/path/to/folder/"
    
          



Additional information on how to define behavior on activation, deactivation, etc. virtual environments is located here .

+1


source







All Articles