Files
local_machine/docs/disk_cleanup/cleanup-disk-now.sh
ahauimix 0238aa7c02 Add Object B and self-growth canons with Cursor ledger rules; refresh connectivity and VPN runbooks.
Track day metrics/anamnesis HARD rules under .cursor/rules and personal docs so each screening updates days/{KIN}, dynamics, and big-data ledger.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-26 10:22:56 +08:00

116 lines
5.1 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# Безопасная очистка диска — по списку из docs/disk_cleanup/DISK_CLEANUP.md.
# Запрещено удалять: docs/disk_cleanup/DO_NOT_DELETE.md
set -e
echo "🧹 Безопасная очистка диска (см. DO_NOT_DELETE.md)"
echo "=========================================================="
echo ""
cleanup_dir() {
local dir="$1"
local name="$2"
if [ -d "$dir" ] || [ -f "$dir" ]; then
size=$(du -sh "$dir" 2>/dev/null | cut -f1)
echo "🗑️ Удаление $name ($size)..."
rm -rf "$dir" 2>/dev/null && echo "$name очищен" || echo " ⚠️ Не удалось удалить $name"
else
echo " $name не найден, пропускаем"
fi
}
echo "📊 Текущее состояние диска:"
df -h / | tail -1
echo ""
# 1. Кэши разработки: Colima, npm, node-gyp, TypeScript, pip, .yarn
echo "=== 1. Кэши разработки ==="
cleanup_dir "$HOME/.colima" "Colima кэш"
cleanup_dir "$HOME/Library/Caches/colima" "Colima кэш (Library)"
cleanup_dir "$HOME/.npm" "npm кэш"
cleanup_dir "$HOME/Library/Caches/node-gyp" "node-gyp кэш"
cleanup_dir "$HOME/Library/Caches/typescript" "TypeScript кэш"
cleanup_dir "$HOME/Library/Caches/pip" "pip кэш"
cleanup_dir "$HOME/.yarn" ".yarn кэш"
cleanup_dir "$HOME/Library/Caches/ms-playwright" "Playwright кэш (браузеры для тестов)"
echo ""
# 2. Кэши браузеров (только ~/Library/Caches — не Application Support)
echo "=== 2. Кэши браузеров ==="
cleanup_dir "$HOME/Library/Caches/Google" "Google кэш"
cleanup_dir "$HOME/Library/Caches/Firefox" "Firefox кэш"
cleanup_dir "$HOME/Library/Caches/BraveSoftware" "Brave кэш"
cleanup_dir "$HOME/Library/Caches/com.brave.Browser" "Brave Browser кэш"
echo ""
# 3. Приложения — Notion, zoom, LibreOffice, Movavi, Ledger (Telegram в DO_NOT_DELETE)
echo "=== 3. Кэши приложений ==="
cleanup_dir "$HOME/Library/Application Support/Notion" "Notion"
cleanup_dir "$HOME/Library/Application Support/zoom.us" "zoom.us"
cleanup_dir "$HOME/Library/Application Support/LibreOffice" "LibreOffice"
cleanup_dir "$HOME/Library/Application Support/Movavi" "Movavi"
cleanup_dir "$HOME/Library/Application Support/Ledger Live" "Ledger Live"
echo ""
# 4. Cursor — только разрешённые кэши и state backup (~10 GB)
echo "=== 4. Cursor кэши (только разрешённые) ==="
cleanup_dir "$HOME/Library/Application Support/Cursor/User/globalStorage/state.vscdb.backup" "state.vscdb.backup"
cleanup_dir "$HOME/Library/Caches/com.todesktop.230313mzl4w4u92.ShipIt" "Cursor ShipIt"
cleanup_dir "$HOME/Library/Application Support/Cursor/WebStorage" "Cursor WebStorage"
cleanup_dir "$HOME/Library/Application Support/Cursor/Partitions" "Cursor Partitions"
cleanup_dir "$HOME/.cursor/projects" "Cursor projects"
echo ""
# 5. Homebrew, .cache, пустые логи
echo "=== 5. Homebrew, .cache, пустые логи ==="
cleanup_dir "$HOME/Library/Caches/anytype-updater" "anytype-updater кэш"
cleanup_dir "$HOME/Library/Caches/Homebrew" "Homebrew кэш"
cleanup_dir "$HOME/.cache" ".cache"
find "$HOME/Library/Logs" -type f -size 0 -delete 2>/dev/null && echo " ✅ Пустые логи удалены" || true
echo ""
# 6. Кэши игр (Wine/GPTK/DXMT — перекачаются скриптами установки)
echo "=== 6. Кэши игр ==="
cleanup_dir "$HOME/code/local_machine/scripts/games/cache" "scripts/games/cache"
echo ""
# 7. Build артефакты (исключая hunabapp-dev/frontend/android — в DO_NOT_DELETE)
echo "=== 7. Build артефакты в ~/code (кроме android) ==="
find "$HOME/code" -type d \( -name "build" -o -name "dist" -o -name ".next" -o -name "out" \) \
-not -path "*/node_modules/*" \
-not -path "*/venv/*" \
-not -path "*/.venv/*" \
-not -path "*/site-packages/*" \
-not -path "*/env/*" \
-not -path "*/hunabapp-dev/frontend/android/*" \
-exec rm -rf {} + 2>/dev/null || true
echo " ✅ Готово"
echo ""
# 8. node_modules (НЕ frontend — в DO_NOT_DELETE)
echo "=== 8. node_modules (кроме hunabapp-dev/frontend) ==="
find "$HOME/code" -type d -name "node_modules" \
-not -path "*/venv/*" \
-not -path "*/.venv/*" \
-not -path "*/hunabapp-dev/frontend/node_modules" \
-exec rm -rf {} + 2>/dev/null || true
echo " ✅ Готово. В нужных проектах: pnpm install"
echo ""
# 9. UTM виртуальная машина
echo "=== 9. UTM виртуальная машина ==="
cleanup_dir "$HOME/code/Parrot-home-mate-6.4_arm64.utm" "UTM виртуальная машина"
echo ""
echo "=========================================================="
echo "📊 Состояние диска после очистки:"
df -h / | tail -1
echo ""
echo "✅ Очистка завершена. Перезапустите приложения при необходимости."
echo " Разрешено: docs/disk_cleanup/DISK_CLEANUP.md"
echo " Запрещено: docs/disk_cleanup/DO_NOT_DELETE.md"
echo ""