-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestvenv_setup.sh
More file actions
executable file
·41 lines (34 loc) · 1.14 KB
/
testvenv_setup.sh
File metadata and controls
executable file
·41 lines (34 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/bash
# setup_testing_venv.sh — Create test_venv and link alias to ~/tests
echo "[SETUP] Creating ~/venvs and ~/tests directories..."
mkdir -p ~/venvs
mkdir -p ~/tests
echo "[SETUP] Creating virtual environment: test_venv"
python3 -m venv ~/venvs/test_venv
echo "[SETUP] Adding alias to ~/.bashrc"
ALIAS_LINE="alias testvenv='source ~/venvs/test_venv/bin/activate && cd ~/tests'"
if ! grep -Fxq "$ALIAS_LINE" ~/.bashrc; then
echo "$ALIAS_LINE" >> ~/.bashrc
echo "[SETUP] Alias added to .bashrc"
else
echo "[INFO] Alias already exists in .bashrc"
fi
echo "[SETUP] Adding one-time login message to ~/.bashrc"
LOGIN_MARKER="# >>> testvenv login message >>>"
if ! grep -Fxq "$LOGIN_MARKER" ~/.bashrc; then
cat << 'EOF' >> ~/.bashrc
# >>> testvenv login message >>>
if [[ $- == *i* ]]; then
CYAN='\033[0;36m'
NC='\033[0m'
echo -e "\n${CYAN}Test Virtual Environment:${NC} testvenv\n"
fi
# <<< testvenv login message <<<
EOF
echo "[SETUP] Login message added to .bashrc"
else
echo "[INFO] Login message already present in .bashrc"
fi
echo "[SETUP] Reloading .bashrc"
source ~/.bashrc
echo "[DONE] You can now run: testvenv"