> For the complete documentation index, see [llms.txt](https://rodneycheung.gitbook.io/handbook/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://rodneycheung.gitbook.io/handbook/2.-huan-jing-pian/kai-fa-huan-jing-pei-zhi/tong-yong/brew_install.md).

# Homebrew安装与使用

## Homebrew安装

### 一、脚本安装(Recommended)

使用下面命令即可一键安装`homebrew`:

```bash
 /bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
```

## 二、官方安装

使用下面命令即可安装:

```bash
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
```

## 三、切换国内源

如果使用官方提供的命令进行安装，还需要切换国内源来加速`homebrew`。以中科大源为例：

```bash
替换brew.git:
cd "$(brew --repo)"
git remote set-url origin https://mirrors.ustc.edu.cn/brew.git

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

如果想切回官方源，执行以下命令:

```bash
重置brew.git:
cd "$(brew --repo)"
git remote set-url origin https://github.com/Homebrew/brew.git

重置homebrew-core.git:
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://github.com/Homebrew/homebrew-core.git
```
