Proposing env. variable WORKON_AUTOCD
While auto-changing the directory to a new virtualenv after creation can be annoying (ticket
#220), I almost always want to change directory when activating an env by
workon. This could be customized by an environment variable.
I propose a variable
WORKON_AUTOCD and the following values:
0 - don't change directory automatically
1 - change to the root of the newly-activated environment
2 - if currently working in a virtualenv, try to change to a corresponding directory in the given env; for example, when working in
~/.envs/foo/some/sub/dir and issueing
workon bar, try to change to
~/.envs/bar/some/sub/dir, and to
~/.envs/bar if it doesn't exist.
3 - like 2, but try every parent before falling back to the root of the new environment (i.e.
~/.envs/bar). This would be useful when working in closely related envs.
Yes, there is
cdvirtualenv, but this is painful when not supported by a good tab completion feature; this is present in
bash, but for example not on Windows. Even with tab completion, I'm happy for every command I don't need to issue.
For a start, it would be sufficient to implement "0" and "1".