A safe and user-friendly macOS cache cleaning script that helps you quickly clean various caches and temporary files to free up disk space.
- Safe: Preview mode with confirmation before cleaning
- Smart: Different cleaning strategies for different cache types
- Interactive: Selectively clean specific items
- Logging: Automatic cleaning logs for tracking
- Compatible: Works with macOS default bash 3.2+
# Clone the repository
git clone https://github.com/ThendCN/macos-cache-cleaner.git
cd macos-cache-cleaner
# Make script executable
chmod +x clean_cache.sh
# View available cache space
./clean_cache.sh -s
# Preview cleaning operations (recommended for first use)
./clean_cache.sh -d
# Interactive cleaning
./clean_cache.sh./clean_cache.sh [options]
Options:
-h, --help Show help information
-s, --scan Scan only, no cleaning
-d, --dry-run Preview mode, show what would be cleaned
-a, --auto Auto clean all caches (use with caution)- Application Caches (
~/Library/Caches) - System Logs (
~/Library/Logs) - Generic Cache (
~/.cache) - npm Cache (
~/.npm) - Chrome Cache
- Trash (
~/.Trash) - Yarn Cache
- Gradle Cache
- Xcode Derived Data
MIT License - See LICENSE file for details
一个安全、易用的 macOS 缓存清理脚本,可帮助你快速清理各类缓存和临时文件,释放磁盘空间。
- 安全性: 提供预览模式,清理前二次确认
- 智能清理: 针对不同类型的缓存采用不同的清理策略
- 交互式: 可选择性清理指定项目
- 日志记录: 自动生成清理日志,便于追踪
- 兼容性: 兼容 macOS 默认的 bash 3.2+
# 克隆仓库
git clone https://github.com/ThendCN/macos-cache-cleaner.git
cd macos-cache-cleaner
# 添加执行权限
chmod +x clean_cache.sh
# 查看可清理空间
./clean_cache.sh -s
# 预览清理操作(推荐第一次使用)
./clean_cache.sh -d
# 交互式清理
./clean_cache.sh./clean_cache.sh [选项]
选项:
-h, --help 显示帮助信息
-s, --scan 仅扫描不清理
-d, --dry-run 预览模式,不实际删除文件
-a, --auto 自动清理所有缓存(需谨慎使用)- 应用程序缓存 (
~/Library/Caches) - 系统日志文件 (
~/Library/Logs) - 通用缓存目录 (
~/.cache) - npm缓存 (
~/.npm) - Chrome浏览器缓存
- 废纸篓 (
~/.Trash) - Yarn缓存
- Gradle缓存
- Xcode派生数据
MIT License - 详见 LICENSE 文件
欢迎提交 Issue 和 Pull Request!
- 应用程序缓存保留最近7天的文件
- npm/Yarn缓存清理后会在下次安装包时自动重建
- Chrome缓存清理后首次打开网页可能较慢
- 废纸篓清空后文件无法恢复
- Xcode派生数据清理后下次构建时间会增加
详细文档请查看 README.md