一、安装homebrew
如果命令失败进入官网查看https://brew.sh/
执行下面命令:
1
| /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
二、配置homebrew
1、在配置文件中添加配置
1 2 3 4 5 6
| #如果您使用的是 Bash 而不是 Zsh,可以替换为 .bash_profile 或 .bashrc vi ~/.zshrc # 不存在就添加到文件中 export PATH="/usr/local/bin:$PATH" #刷新配置 source ~/.zshrc
|
2、查看是否安装cask和core
如果找不到Taps目录则没有安装,需要手动安装cask和core
1 2 3 4
| ls /opt/homebrew/Library/Taps/homebrew
# 如果显示一下三个就安装了 homebrew-cask homebrew-core homebrew-services
|
1 2
| brew install homebrew-cask brew install homebrew-core
|
安装后重新查看目录是否存在
三、配置国内镜像
1、修改镜像源
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| # 替换 Homebrew git -C "$(brew --repo)" remote set-url origin https://mirrors.ustc.edu.cn/brew.git
# 替换 Homebrew Core git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
# 替换 Homebrew Cask git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git
# 替换 Homebrew-bottles echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile source ~/.bash_profile
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.zshrc source ~/.zshrc
#更新配置 brew update
|
__END__