249 字
1 分钟
Homebrew 安装及使用
安装 Homebrew
直接复制下面命令到终端即可
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
如果你没有合适的网络环境,可以使用修改后的脚本,按照提示操作
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
Homebrew 命令
# 移除所有 HomeBrew 缓存brew cleanup --prune 0# 移除未安装的软件包brew cleanup -s拓展
Homebrew 清理脚本
#!/bin/bash
# 文件计数file_count=0link_count=0incomplete_count=0
# 清理 HomeBrew Cask 下载缓存for cask_link in $(find ~/Library/Caches/Homebrew/Cask -type l)do # 将 Cask 软件包移至废纸篓 # let file_count++ # trash $(realpath $cask_link) let link_count++ rm $linkdone
# 清理 HomeBrew 下载缓存for link in $(find ~/Library/Caches/Homebrew -type l)do let file_count++ trash $(realpath $link) let link_count++ rm $linkdone
# 获取 *.incomplete 文件数量let incomplete_count=$(ls -l ~/Library/Caches/Homebrew/downloads/*.incomplete | wc -l)# 清理未完成的下载rm ~/Library/Caches/Homebrew/downloads/*.incomplete
# 复数输出函数plural() { if [ $1 -gt 1 ] then echo "$1 $2s" else echo "$1 $2" fi}
# 输出消息提示echo "Pruned $(plural $link_count "symbolic link"), $(plural $file_count "file") and $(plural $incomplete_count "incomplete download") from $(realpath ~/Library/Caches/Homebrew)"
# 调用 `brew cleanup`# echo 'Running `brew cleanup`'# brew cleanup