# Conda:
conda activate myenv
# UV:
cd /path/to/project
source .venv/bin/activate
Typing .venv/bin/activate every time can be tedious, and sometimes you want a default environment no matter where you are. Introducing the uva alias:
. "$HOME/.cargo/env"
alias uva='f() {
if [ -n "$1" ] && [ -f "$1/.venv/bin/activate" ]; then
source "$1/.venv/bin/activate";
elif [ -f ".venv/bin/activate" ]; then
source .venv/bin/activate;
else
source "/home/yeshwanth/.venv/bin/activate";
fi
}; uva'
In the above alias source "/home/yeshwanth/.venv/bin/activate"; is sourcing my home environment which acts as a global python. Please change the path to your home directory.
With this alias, you can now activate environments effortlessly:
# Activate from current folder
uva
# Activate a specific environment directly
uva /path/to/project
If there's no .venv in the current directory, uva will activate the default environment located at /home/yeshwanth/.