- 安装brew
/bin/bash -c "$(curl -fsSL https://gitee.com/ineo6/homebrew-install/raw/master/install.sh)"
- 将homebrew添加到path中
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/jackhou/.zprofile eval "$(/opt/homebrew/bin/brew shellenv)"
- 把brew下载包的地址切换为国内的镜像地址
git -C "$(brew --repo)" remote set-url origin https://mirrors.ustc.edu.cn/brew.git git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git brew update
- 设置bottles镜像
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles/bottles' >> ~/.zprofilesource ~/.zprofile
//查看brew的版本brew -v//更新homebrew自己,把所有的Formula目录更新,并且会对本机已经安装并有更新的软件用*标明brew update//查看命令帮助:brew -help//查看那些已安装的程序需要更新brew outdated//更新单个软件:brew upgrade [包名]例:brew upgrade git//更新所有软件:brew upgrade //安装软件brew install [包名]@版本例:brew install git//卸载brew uninstall [包名]例:brew uninstall git//清理所有包的旧版本 (安装包缓存)brew cleanup 例:brew cleanup -n //显示要删除的内容,但不要实际删除任何内容例:brew cleanup -s //清理缓存,包括下载即使是最新的版本例:brew cleanup --prune=1 //删除所有早于指定时间的缓存文件(天)//清理单个软件旧版本brew cleanup [包名]例:brew cleanup git //查看需要更新的包brew outdated//查看可清理的旧版本包,不执行实际操作brew cleanup -n //锁定某个包brew pin $FORMULA //取消锁定brew unpin $FORMULA //查看包信息brew info [包名]例:brew info git//查看安装列表brew list//查询可用包brew search [包名]例:brew search git//显示包依赖brew deps [包名]例: brew deps git//更新升级brew$ sudo brew update//1.对/usr/local 目录下的文件读写进行root用户授权$ sudo chown -R $USER /usr/local例:$ sudo chown -R lean /usr/local//2.(推荐)安装Homebrew时对安装路径进行指定,直接安装在不需要系统root用户授权就可以自由读写的目录下<install path> -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
来源地址:https://blog.csdn.net/weixin_44289318/article/details/131460001