This guide helps you set up your ~/.bashrc so that the .venv for this project is automatically activated whenever you enter the EXDA-dashboard directory in a new terminal.
You can use your preferred editor:
- With nano:
nano ~/.bashrc - With VS Code:
code ~/.bashrc
# >>> EXDA-dashboard auto-activate venv >>>
exda_dir="/media/psf/Sim_Back_Up/EXDA-dashboard"
venv_dir="$exda_dir/.venv"
if [[ "$PWD" == "$exda_dir"* ]] && [ -d "$venv_dir" ] && [ -z "$VIRTUAL_ENV" ]; then
source "$venv_dir/bin/activate"
fi
# <<< EXDA-dashboard auto-activate venv <<<
- This will auto-activate the
.venvwhenever youcdinto the EXDA-dashboard directory or any of its subfolders. - If you rename or move the project, update the
exda_dirpath accordingly.
- Save the file and either restart your terminal or run:
source ~/.bashrc
- Open a new terminal and
cdinto your project directory:cd /media/psf/Sim_Back_Up/EXDA-dashboard - The prompt should indicate that the
.venvis activated (usually by showing the environment name).
- This setup is safe: it only activates the venv if you are in the project directory (or subfolders), the
.venvexists, and no other venv is active. - If you have other auto-activation logic in your
~/.bashrc, ensure there are no conflicts. - To deactivate, simply run
deactivateor leave the project directory.
- If the venv does not activate, check:
- The path in
exda_dirmatches your project location. - The
.venvfolder exists and is valid. - There are no typos in the snippet.
- The path in
- To remove this feature, simply delete or comment out the snippet from your
~/.bashrc.
For more details, see the main README.md.