Skip to content

Latest commit

 

History

History
64 lines (44 loc) · 1.71 KB

02.hombrew使用.md

File metadata and controls

64 lines (44 loc) · 1.71 KB

Homebrew

arm版本Homebrew安装在/opt/homebrew内,而x86安装在/usr/local。

1 homebrew简单使用

以安装node.js为例:

#查找版本
brew search node

#安装指定版本
brew install homebrew/versions/node@16

#删除指定版本
brew remove homebrew/versions/node@16

2 brew cask

brewcast是在brew 的基础上一个增强的工具,用来安装Mac上的Gui程序应用包(.dmg/.pkg), 比如qq、chrome等。它先下载解压到统一的目录中(/opt/homebrew-cask/Caskroom),省掉了自己去下载、解压、拖拽(安装)等步骤,同样,卸载相当容易与干净。然后再软链到~/Applications/目录下, 非常方便,而且还包含很多在 AppStore 里没有的常用软件。

# 查找版本
brew search brew-cask
==> Formulae
brew-cask-completion  brew-pip

#安装brewcask
brew install brew-cask-completion

#使用
#Use `brew <command> --cask`

3 切换源

# 进入 brew 的仓库根目录
cd "$(brew --repo)"

# 查看默认源
git remote -v
origin	https://github.com/Homebrew/brew (fetch)
origin	https://github.com/Homebrew/brew (push)

# 修改为中科大的源
git remote set-url origin https://mirrors.ustc.edu.cn/brew.git

#同理,修改 homebrew-cask、homebrew-core、homebrew-services 的远程仓库地址:

cd "$(brew --repo)/Library/Taps/homebrew/homebrew-cask"
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git

# origin	https://github.com/Homebrew/homebrew-core (fetch)
# origin	https://github.com/Homebrew/homebrew-core (push)
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git

#修改完仓库地址后,更新一下
brew update -v