这是我参与8月更文挑战的第25天,活动详情查看:8月更文挑战
Homebrew 是 Mac OSX 上的软件包管理工具,能在 Mac 中方便的安装软件或者卸载软件,相当于 Linux 下的 apt-get、yum 神器;Homebre 可以在 Mac 上安装一些 OS X 没有的 UNIX 工具,Homebrew 将这些工具统统安装到了 /usr/local/Cellar 目录中,并在 /usr/local/bin 中创建符号链接。 官网地址:brew.sh/index_zh-cn…
安装
在终端里运行以下命令
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
- 安装完成以后,需要运行
brew doctor
命令检测下是否有什么冲突的地方,如果有可以按照提示处理 - Homebrew 安装成功后,会自动创建目录
/usr/local/Cellar
来存放 Homebrew 安装的程序
基本使用
# 搜索包
brew search mysql
# 安装包
brew install mysql
# 查看包信息,比如目前的版本,依赖,安装后注意事项等
brew info mysql
# 卸载包
brew uninstall wget
# 显示已安装的包
brew list
# 查看brew的帮助
brew –help
# 更新, 这会更新 Homebrew 自己
brew update
# 检查过时(是否有新版本),这会列出所有安装的包里,哪些可以升级
brew outdated
brew outdated mysql
# 升级所有可以升级的软件们
brew upgrade
brew upgrade mysql
# 清理不需要的版本极其安装包缓存
brew cleanup
brew cleanup mysql
配置镜像
使用 清华镜像站点 的镜像
配置索引镜像
git -C "$(brew --repo)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
# git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git
# git -C "$(brew --repo homebrew/cask-fonts)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask-fonts.git
# git -C "$(brew --repo homebrew/cask-drivers)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask-drivers.git
# 更换后测试工作是否正常
brew update
复原索引镜像
git -C "$(brew --repo)" remote set-url origin https://github.com/Homebrew/brew.git
git -C "$(brew --repo homebrew/core)" remote set-url origin https://github.com/Homebrew/homebrew-core.git
# git -C "$(brew --repo homebrew/cask)" remote set-url origin https://github.com/Homebrew/homebrew-cask.git
# git -C "$(brew --repo homebrew/cask-fonts)" remote set-url origin https://github.com/Homebrew/homebrew-cask-fonts.git
# git -C "$(brew --repo homebrew/cask-drivers)" remote set-url origin https://github.com/Homebrew/homebrew-cask-drivers.git
# 更换后测试工作是否正常
brew update
配置二进制预编译包镜像
export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles