For I did not have the choice, I had to set the $WORKON_HOME
and PROJECT_HOME
variables to different path in the .bashrc
(local machine) and .bash_profile
(remote machine) files.
e.g.:
In the .bashrc
file (local):
export WORKON_HOME="$HOME/home-local/.virtualenvs"
export PROJECT_HOME="$HOME/home-local/venv_projects/"
and in the bash_profile
one (remote):
export WORKON_HOME="$HOME/.virtualenvs"
export PROJECT_HOME="$HOME/venv_projects/"
My remote machine is mounted on my local machine under the home-local
folder. I can not change this.
Thus, as I run most of my programs on the remote, I first need to create the virtualenv on the remote machine.
However, if I briefly want to work on my local machine, when I type workon env
, the working directory gets changed to $HOME/.virtualenvs
(as on the remote), instead of $HOME/home-local/.virtualenvs
. I guess the WORKON_HOME
and PROJECT_HOME
variables are tied to the environment.
But is there any way to change this?
Thanks,
You cannot have 2 different values for 1 variable. But you can switch between values. Put
export WORKON_HOME="$HOME/.virtualenvs"
export PROJECT_HOME="$HOME/venv_projects/"
into a file, for example "$HOME"/home.sh, and
export WORKON_HOME="$HOME/home-local/.virtualenvs"
export PROJECT_HOME="$HOME/home-local/venv_projects/"
into, e.g., "$HOME"/home-local.sh. Now you can do source "$HOME"/home.sh
or source "$HOME"/home-local.sh
. And source
can be shortened to just .
: . "$HOME"/home-local.sh
.
You can create aliases or shell functions instead:
home_virt() {
export WORKON_HOME="$HOME/.virtualenvs"
export PROJECT_HOME="$HOME/venv_projects/"
}
home_local_virt() {
export WORKON_HOME="$HOME/home-local/.virtualenvs"
export PROJECT_HOME="$HOME/home-local/venv_projects/"
}
and just call home_virt
or home_local_virt
.