Files
pkgmgr/scripts/uninstall.sh
Kevin Veen-Birkenbach c92fd44dd3
Some checks failed
Mark stable commit / test-unit (push) Has been cancelled
Mark stable commit / test-integration (push) Has been cancelled
Mark stable commit / test-env-virtual (push) Has been cancelled
Mark stable commit / test-env-nix (push) Has been cancelled
Mark stable commit / test-e2e (push) Has been cancelled
Mark stable commit / test-virgin-user (push) Has been cancelled
Mark stable commit / test-virgin-root (push) Has been cancelled
Mark stable commit / codesniffer-shellcheck (push) Has been cancelled
Mark stable commit / codesniffer-ruff (push) Has been cancelled
Mark stable commit / mark-stable (push) Has been cancelled
fix(uninstall): robustly remove pkgmgr venv auto-activation and leftover shell RC entries
2025-12-13 14:48:59 +01:00

43 lines
1.3 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
echo "[uninstall] Starting pkgmgr uninstall..."
VENV_DIR="${HOME}/.venvs/pkgmgr"
# ------------------------------------------------------------
# Remove virtual environment
# ------------------------------------------------------------
echo "[uninstall] Removing global user virtual environment if it exists..."
if [[ -d "$VENV_DIR" ]]; then
rm -rf "$VENV_DIR"
echo "[uninstall] Removed: $VENV_DIR"
else
echo "[uninstall] No venv found at: $VENV_DIR"
fi
# ------------------------------------------------------------
# Remove auto-activation lines from shell RC files
# ------------------------------------------------------------
# Matches:
# ~/.venvs/pkgmgr/bin/activate
# ./.venvs/pkgmgr/bin/activate
RC_PATTERN='(\./)?\.venvs/pkgmgr/bin/activate'
echo "[uninstall] Cleaning up ~/.bashrc and ~/.zshrc entries..."
for rc in "$HOME/.bashrc" "$HOME/.zshrc"; do
if [[ -f "$rc" ]]; then
# Remove activation lines (functional)
sed -E -i "/$RC_PATTERN/d" "$rc"
# Remove leftover echo / cosmetic lines referencing pkgmgr venv
sed -i '/\.venvs\/pkgmgr/d' "$rc"
echo "[uninstall] Cleaned $rc"
else
echo "[uninstall] File not found: $rc (skipped)"
fi
done
echo "[uninstall] Done. Restart your shell (or run 'exec bash' or 'exec zsh') to apply changes."