[TOC] ## 安装 ### 官方安装 `/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" ` ### 通过镜像安装 [安装说明](https://zhuanlan.zhihu.com/p/90508170) ``` /usr/bin/ruby -e "$(curl -fsSL https://cdn.jsdelivr.net/gh/ineo6/homebrew-install/install)" // 卡在 core Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'... //执行 cd "$(brew --repo)/Library/Taps/" mkdir homebrew && cd homebrew git clone git://mirrors.ustc.edu.cn/homebrew-core.git // 卡在 cask , 同理 //执行 cd "$(brew --repo)/Library/Taps/" cd homebrew git clone https://mirrors.ustc.edu.cn/homebrew-cask.git //再执行 /usr/bin/ruby -e "$(curl -fsSL https://cdn.jsdelivr.net/gh/ineo6/homebrew-install/install)" ``` ## 设置镜像 清华大学源 ``` 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 brew update ``` ## brew services 服务管理 ``` brew services Name Status User Plist beanstalkd stopped httpd started root /Library/LaunchDaemons/homebrew.mxcl.httpd.plist memcached stopped mysql@5.6 started root /Library/LaunchDaemons/homebrew.mxcl.mysql@5.6.plist nginx started idcpj /Users/idcpj/Library/LaunchAgents/homebrew.mxcl.nginx.plist redis stopped unbound stopped ``` 如果User 为root 需要用 sudo 启动,切换用户普通用户 可用非sudo 的方式启动 ``` 列出服务 [sudo] brew services [list] 非注册服务方式启动 [sudo] brew services run (服务名|--all) [sudo] brew services start (服务名|--all) [sudo] brew services stop (服务名|--all) [sudo] brew services restart (服务名|--all) 移除所有在跑的服务 [sudo] brew services cleanup ``` ## 命令 ``` brew search git 搜索 brew install git 安装 brew uninstall git 卸载 brew upgrade git 升级 brew info git 查看信息 brew cleanup git 清楚老版本 brew unlink git Unlink brew link git Link brew list --versions git 查看版本 brew switch git 2.5.0 切换版本 //cask brew cask install firefox 安装界面应用 brew cask list 列出安装应用 //global brew outdated 检查老版本 brew upgrade 更新所有应用 brew cleanup 删除应用的旧版本和缓存删除 brew doctor 检查 brew list 列出安装应用 brew services 类似linux的方式管理 ```