-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathactivate.sh
More file actions
48 lines (41 loc) · 1.22 KB
/
activate.sh
File metadata and controls
48 lines (41 loc) · 1.22 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
42
43
44
45
46
47
48
#!/usr/bin/env bash
#
# Activate Python-NoAdmin environment in the current shell session.
#
# Usage: source ./scripts/activate.sh
#
INSTALL_DIR="${HOME}/.python-nonadmin"
BIN_DIR="${INSTALL_DIR}/bin"
# Check if installed
if [ ! -d "$INSTALL_DIR" ]; then
echo "[ERROR] Python-NoAdmin not installed at: $INSTALL_DIR"
echo "Run install.sh first."
return 1 2>/dev/null || exit 1
fi
# Store original PATH for deactivation
if [ -z "$_PYTHON_NONADMIN_OLD_PATH" ]; then
export _PYTHON_NONADMIN_OLD_PATH="$PATH"
fi
# Add to PATH
export PATH="${BIN_DIR}:${PATH}"
# Set marker for compatibility
export PYTHON_NONADMIN_ACTIVE="1"
# Define deactivate function
deactivate_python_nonadmin() {
if [ -n "$_PYTHON_NONADMIN_OLD_PATH" ]; then
export PATH="$_PYTHON_NONADMIN_OLD_PATH"
unset _PYTHON_NONADMIN_OLD_PATH
fi
unset PYTHON_NONADMIN_ACTIVE
unset -f deactivate_python_nonadmin 2>/dev/null
echo "[INFO] Python-NoAdmin deactivated"
}
# Confirmation
PYTHON_VERSION=$("${BIN_DIR}/python3" --version 2>&1)
echo ""
echo -e "\033[0;32m[SUCCESS]\033[0m Python-NoAdmin activated"
echo " Python: ${PYTHON_VERSION}"
echo " Location: ${INSTALL_DIR}"
echo ""
echo " To deactivate: deactivate_python_nonadmin"
echo ""