Skip to content

Instantly share code, notes, and snippets.

@swateek
Last active March 2, 2026 16:39
Show Gist options
  • Select an option

  • Save swateek/9a9c89fae5900ce1c31e596a8fe4a8cb to your computer and use it in GitHub Desktop.

Select an option

Save swateek/9a9c89fae5900ce1c31e596a8fe4a8cb to your computer and use it in GitHub Desktop.
Vagrant Cleanup Script
#!/bin/bash
CYAN='\033[0;36m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
BOLD='\033[1m'
NC='\033[0m'
# Use $HOME by default, or override with CLEANUP_HOME env var
# e.g. CLEANUP_HOME=/home/otheruser ~/cleanup.sh
CLEANUP_HOME="${CLEANUP_HOME:-$HOME}"
TOTAL_FREED=0
AUTO_CONFIRM=false
print_header() {
echo ""
echo -e "${BOLD}${CYAN}========================================${NC}"
echo -e "${BOLD}${CYAN} $1${NC}"
echo -e "${BOLD}${CYAN}========================================${NC}"
}
print_size() {
du -sh "$1" 2>/dev/null | cut -f1
}
bytes_to_human() {
numfmt --to=iec "$1" 2>/dev/null || echo "${1}B"
}
get_dir_bytes() {
du -sb "$1" 2>/dev/null | cut -f1
}
confirm() {
if $AUTO_CONFIRM; then
return 0
fi
read -rp "⚠️ $1 (yes/no): " CONFIRM
[[ "$CONFIRM" == "yes" ]]
}
freed_message() {
echo -e "${GREEN}βœ… Freed: $1${NC}"
}
skip_message() {
echo -e "${YELLOW}⏭️ Skipped.${NC}"
}
# ─────────────────────────────────────────
# 1. Terraform .terraform directories
# ─────────────────────────────────────────
cleanup_terraform() {
print_header "Terraform Provider Cache (.terraform)"
mapfile -t DIRS < <(find "$CLEANUP_HOME" -type d -name ".terraform" 2>/dev/null)
if [ ${#DIRS[@]} -eq 0 ]; then
echo " No .terraform directories found."
return
fi
echo ""
for i in "${!DIRS[@]}"; do
SIZE=$(print_size "${DIRS[$i]}")
echo " [$i] $SIZE ${DIRS[$i]}"
done
if $AUTO_CONFIRM; then
CHOICE="a"
else
echo ""
echo " Options: (a)ll (s)elect indexes (n)one"
read -rp " Choice: " CHOICE
fi
case "$CHOICE" in
a)
BEFORE=0
for DIR in "${DIRS[@]}"; do
BEFORE=$((BEFORE + $(get_dir_bytes "$DIR")))
rm -rf "$DIR"
echo " πŸ—‘οΈ Deleted: $DIR"
done
TOTAL_FREED=$((TOTAL_FREED + BEFORE))
freed_message "$(bytes_to_human $BEFORE)"
;;
s)
read -rp " Enter indexes (e.g. 0,2,4): " INDEXES
IFS=',' read -ra SELECTED <<< "$INDEXES"
BEFORE=0
for i in "${SELECTED[@]}"; do
i=$(echo "$i" | tr -d ' ')
if [[ -n "${DIRS[$i]}" ]]; then
BEFORE=$((BEFORE + $(get_dir_bytes "${DIRS[$i]}")))
rm -rf "${DIRS[$i]}"
echo " πŸ—‘οΈ Deleted: ${DIRS[$i]}"
else
echo " ⚠️ Invalid index: $i β€” skipping"
fi
done
TOTAL_FREED=$((TOTAL_FREED + BEFORE))
freed_message "$(bytes_to_human $BEFORE)"
;;
*)
skip_message
;;
esac
}
# ─────────────────────────────────────────
# 2. Playwright browser cache
# ─────────────────────────────────────────
cleanup_playwright() {
print_header "Playwright Browser Cache"
PLAYWRIGHT_DIRS=(
"$CLEANUP_HOME/.cache/ms-playwright"
"$CLEANUP_HOME/.cache/ms-playwright-go"
)
FOUND=0
for DIR in "${PLAYWRIGHT_DIRS[@]}"; do
if [ -d "$DIR" ]; then
SIZE=$(print_size "$DIR")
echo " πŸ“ $SIZE $DIR"
FOUND=1
fi
done
if [ $FOUND -eq 0 ]; then
echo " No Playwright cache found."
return
fi
echo ""
if confirm "Delete Playwright browser cache?"; then
BEFORE=0
for DIR in "${PLAYWRIGHT_DIRS[@]}"; do
if [ -d "$DIR" ]; then
BEFORE=$((BEFORE + $(get_dir_bytes "$DIR")))
rm -rf "$DIR"
echo " πŸ—‘οΈ Deleted: $DIR"
fi
done
TOTAL_FREED=$((TOTAL_FREED + BEFORE))
freed_message "$(bytes_to_human $BEFORE)"
else
skip_message
fi
}
# ─────────────────────────────────────────
# 3. APT package cache
# ─────────────────────────────────────────
cleanup_apt() {
print_header "APT Package Cache"
SIZE=$(print_size "/var/cache/apt")
echo " πŸ“ $SIZE /var/cache/apt"
echo ""
if confirm "Run apt clean, autoclean, and autoremove?"; then
BEFORE=$(get_dir_bytes "/var/cache/apt")
sudo apt-get clean -y
sudo apt-get autoclean -y
sudo apt-get autoremove -y --purge
AFTER=$(get_dir_bytes "/var/cache/apt")
DIFF=$((BEFORE - AFTER))
TOTAL_FREED=$((TOTAL_FREED + DIFF))
freed_message "$(bytes_to_human $DIFF)"
else
skip_message
fi
}
# ─────────────────────────────────────────
# 4. Journal logs
# ─────────────────────────────────────────
cleanup_journal() {
print_header "Systemd Journal Logs"
SIZE=$(journalctl --disk-usage 2>/dev/null | grep -oP '[\d.]+\s*\w+(?= on disk)')
echo " πŸ“ Journal logs currently using: ${SIZE:-unknown}"
echo ""
if confirm "Truncate journal logs to last 7 days / 50MB max?"; then
sudo journalctl --vacuum-time=7d
sudo journalctl --vacuum-size=50M
freed_message "Journal logs truncated"
else
skip_message
fi
}
# ─────────────────────────────────────────
# 5. Temp files
# ─────────────────────────────────────────
cleanup_tmp() {
print_header "Temp Files (/tmp, /var/tmp)"
TMP_SIZE=$(print_size "/tmp")
VAR_TMP_SIZE=$(print_size "/var/tmp")
echo " πŸ“ $TMP_SIZE /tmp"
echo " πŸ“ $VAR_TMP_SIZE /var/tmp"
echo ""
if confirm "Clear /tmp and /var/tmp?"; then
BEFORE=$(($(get_dir_bytes "/tmp") + $(get_dir_bytes "/var/tmp")))
sudo rm -rf /tmp/* /var/tmp/*
TOTAL_FREED=$((TOTAL_FREED + BEFORE))
freed_message "$(bytes_to_human $BEFORE)"
else
skip_message
fi
}
# ─────────────────────────────────────────
# 6. Old log files
# ─────────────────────────────────────────
cleanup_logs() {
print_header "Old Log Files (/var/log)"
SIZE=$(print_size "/var/log")
echo " πŸ“ $SIZE /var/log (compressed/rotated logs)"
echo ""
if confirm "Remove compressed and rotated log files (*.gz, *.old)?"; then
BEFORE=$(find /var/log -type f \( -name "*.gz" -o -name "*.old" \) -exec du -sb {} + 2>/dev/null | awk '{sum+=$1} END{print sum+0}')
sudo find /var/log -type f \( -name "*.gz" -o -name "*.old" \) -delete
TOTAL_FREED=$((TOTAL_FREED + BEFORE))
freed_message "$(bytes_to_human $BEFORE)"
else
skip_message
fi
}
# ─────────────────────────────────────────
# 7. NPM cache
# ─────────────────────────────────────────
cleanup_npm() {
print_header "NPM Cache"
NPM_CACHE="$CLEANUP_HOME/.npm"
if [ ! -d "$NPM_CACHE" ]; then
echo " No NPM cache found."
return
fi
SIZE=$(print_size "$NPM_CACHE")
echo " πŸ“ $SIZE $NPM_CACHE"
echo ""
if confirm "Clear NPM cache?"; then
BEFORE=$(get_dir_bytes "$NPM_CACHE")
npm cache clean --force 2>/dev/null
AFTER=$(get_dir_bytes "$NPM_CACHE")
DIFF=$((BEFORE - AFTER))
TOTAL_FREED=$((TOTAL_FREED + DIFF))
freed_message "$(bytes_to_human $DIFF)"
else
skip_message
fi
}
# ─────────────────────────────────────────
# 8. NVM old Node versions
# ─────────────────────────────────────────
cleanup_nvm() {
print_header "NVM β€” Old Node Versions"
NVM_DIR="$CLEANUP_HOME/.nvm/versions/node"
if [ ! -d "$NVM_DIR" ]; then
echo " NVM not found."
return
fi
CURRENT=$(node --version 2>/dev/null)
echo " Current active Node version: ${CURRENT:-unknown}"
echo ""
mapfile -t VERSIONS < <(ls "$NVM_DIR")
if [ ${#VERSIONS[@]} -le 1 ]; then
echo " Only one Node version installed, nothing to prune."
return
fi
echo " Installed versions:"
for i in "${!VERSIONS[@]}"; do
SIZE=$(print_size "$NVM_DIR/${VERSIONS[$i]}")
ACTIVE=""
[[ "v${VERSIONS[$i]#v}" == "$CURRENT" ]] && ACTIVE=" ← current"
echo " [$i] $SIZE ${VERSIONS[$i]}$ACTIVE"
done
echo ""
if $AUTO_CONFIRM; then
# In auto mode, delete all non-current versions
BEFORE=0
for i in "${!VERSIONS[@]}"; do
VER_PATH="$NVM_DIR/${VERSIONS[$i]}"
if [[ "v${VERSIONS[$i]#v}" == "$CURRENT" ]]; then
echo " ⏭️ Keeping current: ${VERSIONS[$i]}"
else
BEFORE=$((BEFORE + $(get_dir_bytes "$VER_PATH")))
rm -rf "$VER_PATH"
echo " πŸ—‘οΈ Deleted: ${VERSIONS[$i]}"
fi
done
TOTAL_FREED=$((TOTAL_FREED + BEFORE))
freed_message "$(bytes_to_human $BEFORE)"
else
echo " Options: (s)elect indexes to delete (n)one"
read -rp " Choice: " CHOICE
case "$CHOICE" in
s)
read -rp " Enter indexes to delete (e.g. 0,2): " INDEXES
IFS=',' read -ra SELECTED <<< "$INDEXES"
BEFORE=0
for i in "${SELECTED[@]}"; do
i=$(echo "$i" | tr -d ' ')
if [[ -n "${VERSIONS[$i]}" ]]; then
VER_PATH="$NVM_DIR/${VERSIONS[$i]}"
if [[ "v${VERSIONS[$i]#v}" == "$CURRENT" ]]; then
echo " ⚠️ Skipping current version: ${VERSIONS[$i]}"
else
BEFORE=$((BEFORE + $(get_dir_bytes "$VER_PATH")))
rm -rf "$VER_PATH"
echo " πŸ—‘οΈ Deleted: ${VERSIONS[$i]}"
fi
else
echo " ⚠️ Invalid index: $i β€” skipping"
fi
done
TOTAL_FREED=$((TOTAL_FREED + BEFORE))
freed_message "$(bytes_to_human $BEFORE)"
;;
*)
skip_message
;;
esac
fi
}
# ─────────────────────────────────────────
# 9. Zsh completion dumps
# ─────────────────────────────────────────
cleanup_zcompdump() {
print_header "Zsh Completion Dumps (.zcompdump*)"
mapfile -t FILES < <(find "$CLEANUP_HOME" -maxdepth 1 -name ".zcompdump*" 2>/dev/null)
if [ ${#FILES[@]} -eq 0 ]; then
echo " No .zcompdump files found."
return
fi
BEFORE=0
for f in "${FILES[@]}"; do
SIZE=$(print_size "$f")
BYTES=$(get_dir_bytes "$f")
BEFORE=$((BEFORE + BYTES))
echo " πŸ“„ $SIZE $f"
done
echo ""
if confirm "Delete all .zcompdump files? (they regenerate automatically)"; then
for f in "${FILES[@]}"; do
rm -f "$f"
echo " πŸ—‘οΈ Deleted: $f"
done
TOTAL_FREED=$((TOTAL_FREED + BEFORE))
freed_message "$(bytes_to_human $BEFORE)"
else
skip_message
fi
}
# ─────────────────────────────────────────
# 10. Cursor server old versions
# ─────────────────────────────────────────
cleanup_cursor_server() {
print_header "Cursor Server β€” Old Versions"
CURSOR_SERVER_DIR="$CLEANUP_HOME/.cursor-server"
if [ ! -d "$CURSOR_SERVER_DIR" ]; then
echo " No .cursor-server directory found."
return
fi
mapfile -t VERSIONS < <(ls "$CURSOR_SERVER_DIR" 2>/dev/null)
if [ ${#VERSIONS[@]} -le 1 ]; then
echo " Only one Cursor server version installed, nothing to prune."
return
fi
echo " Installed versions (newest last):"
for i in "${!VERSIONS[@]}"; do
SIZE=$(print_size "$CURSOR_SERVER_DIR/${VERSIONS[$i]}")
echo " [$i] $SIZE ${VERSIONS[$i]}"
done
LATEST_IDX=$(( ${#VERSIONS[@]} - 1 ))
echo ""
if $AUTO_CONFIRM; then
# Keep only the latest version
BEFORE=0
for i in "${!VERSIONS[@]}"; do
if [ "$i" -eq "$LATEST_IDX" ]; then
echo " ⏭️ Keeping latest: ${VERSIONS[$i]}"
else
VER_PATH="$CURSOR_SERVER_DIR/${VERSIONS[$i]}"
BEFORE=$((BEFORE + $(get_dir_bytes "$VER_PATH")))
rm -rf "$VER_PATH"
echo " πŸ—‘οΈ Deleted: ${VERSIONS[$i]}"
fi
done
TOTAL_FREED=$((TOTAL_FREED + BEFORE))
freed_message "$(bytes_to_human $BEFORE)"
else
echo " Tip: Keep the highest-numbered version, delete the rest."
echo " Options: (s)elect indexes to delete (n)one"
read -rp " Choice: " CHOICE
case "$CHOICE" in
s)
read -rp " Enter indexes to delete (e.g. 0,1): " INDEXES
IFS=',' read -ra SELECTED <<< "$INDEXES"
BEFORE=0
for i in "${SELECTED[@]}"; do
i=$(echo "$i" | tr -d ' ')
if [[ -n "${VERSIONS[$i]}" ]]; then
VER_PATH="$CURSOR_SERVER_DIR/${VERSIONS[$i]}"
BEFORE=$((BEFORE + $(get_dir_bytes "$VER_PATH")))
rm -rf "$VER_PATH"
echo " πŸ—‘οΈ Deleted: ${VERSIONS[$i]}"
else
echo " ⚠️ Invalid index: $i β€” skipping"
fi
done
TOTAL_FREED=$((TOTAL_FREED + BEFORE))
freed_message "$(bytes_to_human $BEFORE)"
;;
*)
skip_message
;;
esac
fi
}
# ─────────────────────────────────────────
# 11. Virtualenv cache
# ─────────────────────────────────────────
cleanup_virtualenv() {
print_header "Virtualenv Cache"
VENV_CACHE="$CLEANUP_HOME/.local/share/virtualenv"
if [ ! -d "$VENV_CACHE" ]; then
echo " No virtualenv cache found."
return
fi
SIZE=$(print_size "$VENV_CACHE")
echo " πŸ“ $SIZE $VENV_CACHE"
echo ""
if confirm "Clear virtualenv cache?"; then
BEFORE=$(get_dir_bytes "$VENV_CACHE")
rm -rf "$VENV_CACHE"
TOTAL_FREED=$((TOTAL_FREED + BEFORE))
freed_message "$(bytes_to_human $BEFORE)"
else
skip_message
fi
}
# ─────────────────────────────────────────
# 12. General .cache sweep
# ─────────────────────────────────────────
cleanup_cache() {
print_header "General Cache (~/.cache)"
CACHE_DIR="$CLEANUP_HOME/.cache"
if [ ! -d "$CACHE_DIR" ]; then
echo " No .cache directory found."
return
fi
echo " Cache subdirectories:"
mapfile -t SUBDIRS < <(find "$CACHE_DIR" -maxdepth 1 -mindepth 1 -type d 2>/dev/null | sort)
TOTAL_CACHE=0
for i in "${!SUBDIRS[@]}"; do
NAME=$(basename "${SUBDIRS[$i]}")
[[ "$NAME" == "ms-playwright" || "$NAME" == "ms-playwright-go" ]] && continue
SIZE=$(print_size "${SUBDIRS[$i]}")
BYTES=$(get_dir_bytes "${SUBDIRS[$i]}")
TOTAL_CACHE=$((TOTAL_CACHE + BYTES))
echo " [$i] $SIZE $NAME"
done
echo ""
echo " Total: $(bytes_to_human $TOTAL_CACHE)"
echo ""
if $AUTO_CONFIRM; then
BEFORE=0
for DIR in "${SUBDIRS[@]}"; do
NAME=$(basename "$DIR")
[[ "$NAME" == "ms-playwright" || "$NAME" == "ms-playwright-go" ]] && continue
BEFORE=$((BEFORE + $(get_dir_bytes "$DIR")))
rm -rf "$DIR"
echo " πŸ—‘οΈ Deleted: $NAME"
done
TOTAL_FREED=$((TOTAL_FREED + BEFORE))
freed_message "$(bytes_to_human $BEFORE)"
else
echo " Options: (a)ll (s)elect indexes (n)one"
read -rp " Choice: " CHOICE
case "$CHOICE" in
a)
if confirm "Delete ALL .cache subdirectories (except Playwright)?"; then
BEFORE=0
for DIR in "${SUBDIRS[@]}"; do
NAME=$(basename "$DIR")
[[ "$NAME" == "ms-playwright" || "$NAME" == "ms-playwright-go" ]] && continue
BEFORE=$((BEFORE + $(get_dir_bytes "$DIR")))
rm -rf "$DIR"
echo " πŸ—‘οΈ Deleted: $NAME"
done
TOTAL_FREED=$((TOTAL_FREED + BEFORE))
freed_message "$(bytes_to_human $BEFORE)"
else
skip_message
fi
;;
s)
read -rp " Enter indexes (e.g. 0,2,4): " INDEXES
IFS=',' read -ra SELECTED <<< "$INDEXES"
BEFORE=0
for i in "${SELECTED[@]}"; do
i=$(echo "$i" | tr -d ' ')
if [[ -n "${SUBDIRS[$i]}" ]]; then
BEFORE=$((BEFORE + $(get_dir_bytes "${SUBDIRS[$i]}")))
rm -rf "${SUBDIRS[$i]}"
echo " πŸ—‘οΈ Deleted: $(basename "${SUBDIRS[$i]}")"
else
echo " ⚠️ Invalid index: $i β€” skipping"
fi
done
TOTAL_FREED=$((TOTAL_FREED + BEFORE))
freed_message "$(bytes_to_human $BEFORE)"
;;
*)
skip_message
;;
esac
fi
}
# ─────────────────────────────────────────
# 13. Mozilla Firefox cache
# ─────────────────────────────────────────
cleanup_mozilla() {
print_header "Mozilla Firefox Cache"
FIREFOX_DIR="$CLEANUP_HOME/.mozilla/firefox"
if [ ! -d "$FIREFOX_DIR" ]; then
echo " No Firefox profile found."
return
fi
mapfile -t CACHE_DIRS < <(find "$FIREFOX_DIR" -maxdepth 2 -type d \( -name "cache2" -o -name "startupCache" -o -name "jumpListCache" \) 2>/dev/null)
if [ ${#CACHE_DIRS[@]} -eq 0 ]; then
echo " No Firefox cache directories found."
return
fi
BEFORE=0
for DIR in "${CACHE_DIRS[@]}"; do
SIZE=$(print_size "$DIR")
BYTES=$(get_dir_bytes "$DIR")
BEFORE=$((BEFORE + BYTES))
echo " πŸ“ $SIZE $DIR"
done
echo ""
if confirm "Clear Firefox cache directories? (profile/bookmarks/passwords are untouched)"; then
for DIR in "${CACHE_DIRS[@]}"; do
rm -rf "$DIR"
echo " πŸ—‘οΈ Deleted: $DIR"
done
TOTAL_FREED=$((TOTAL_FREED + BEFORE))
freed_message "$(bytes_to_human $BEFORE)"
else
skip_message
fi
}
# ─────────────────────────────────────────
# MAIN
# ─────────────────────────────────────────
clear
echo -e "${BOLD}${CYAN}"
echo " β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ•—β–ˆβ–ˆβ•— β–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— "
echo " β–ˆβ–ˆβ•”β•β•β•β•β•β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•”β•β•β•β•β•β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—"
echo " β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β–ˆβ–ˆβ•— β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•"
echo " β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•”β•β•β• β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β•β• "
echo " β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘ β•šβ–ˆβ–ˆβ–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘ "
echo " β•šβ•β•β•β•β•β•β•šβ•β•β•β•β•β•β•β•šβ•β•β•β•β•β•β•β•šβ•β• β•šβ•β•β•šβ•β• β•šβ•β•β•β• β•šβ•β•β•β•β•β• β•šβ•β• "
echo -e "${NC}"
echo -e " ${BOLD}Vagrant Box Disk Cleanup Utility${NC}"
echo -e " Run this script regularly to keep your box clean."
echo -e " Home directory: ${CYAN}$CLEANUP_HOME${NC}"
echo ""
echo -e "${BOLD}Current Disk Usage:${NC}"
df -h / | tail -1 | awk '{printf " Used: %s / %s (%s full)\n", $3, $2, $5}'
echo ""
# ─── Single upfront prompt ───────────────
echo -e "${BOLD}${YELLOW}Run mode:${NC}"
echo " (y) Auto β€” clean everything without prompts (NVM/Cursor keep latest only)"
echo " (n) Interactive β€” confirm each section individually"
echo ""
read -rp " Auto-clean everything? (y/n): " RUN_MODE
echo ""
if [[ "$RUN_MODE" == "y" || "$RUN_MODE" == "yes" ]]; then
AUTO_CONFIRM=true
echo -e "${GREEN} Running in auto mode β€” cleaning all sections...${NC}"
else
AUTO_CONFIRM=false
echo -e "${CYAN} Running in interactive mode β€” you'll be asked per section.${NC}"
fi
echo ""
cleanup_terraform
cleanup_playwright
cleanup_npm
cleanup_nvm
cleanup_zcompdump
cleanup_cursor_server
cleanup_virtualenv
cleanup_cache
cleanup_mozilla
cleanup_apt
cleanup_journal
cleanup_tmp
cleanup_logs
# ─────────────────────────────────────────
# SUMMARY
# ─────────────────────────────────────────
print_header "Cleanup Summary"
echo -e " ${BOLD}${GREEN}Total space freed: $(bytes_to_human $TOTAL_FREED)${NC}"
echo ""
echo -e "${BOLD}Disk Usage After Cleanup:${NC}"
df -h / | tail -1 | awk '{printf " Used: %s / %s (%s full)\n", $3, $2, $5}'
echo ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment