Homebrew官方的源一般下载包之类的会很慢,所以通常我们都是用国内的镜像源来代替,这样会提高我们的效率。Homebrew主要有四个部分组成: brew、homebrew-core 、homebrew-bottles、homebrew-cask。
名称 说明
brew Homebrew 源代码仓库
homebrew-core Homebrew 核心软件仓库
homebrew-bottles Homebrew 预编译二进制软件包
homebrew-cask MacOS 客户端应用
Homebrew国内镜像源目前主要有中科大镜像、阿里镜像、清华镜像。
前言
mac的终端是bash还是zsh?
在macOS中,终端默认使用的shell是bash。但是,一些用户可能已经将默认shell更改为zsh。你可以通过以下命令检查你的终端使用的是哪个shell:
如果输出是/bin/bash,那么你的终端使用的是bash。如果输出是/bin/zsh,那么你的终端使用的是zsh。
1、替换为中科大源
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| $ cd "$(brew --repo)" && git remote -v origin https://github.com/Homebrew/brew.git (fetch) origin https://github.com/Homebrew/brew.git (push)
$ cd "$(brew --repo homebrew/core)" && git remote -v origin https://github.com/Homebrew/homebrew-core.git (fetch) origin https://github.com/Homebrew/homebrew-core.git (push)
$ git -C "$(brew --repo)" remote set-url origin https://mirrors.ustc.edu.cn/brew.git $ git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git $ git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git
$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.zshrc $ source ~/.zshrc
$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile $ source ~/.bash_profile
$ brew update
|
2、重置为默认源
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| $ 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
$ vi ~/.zshrc
$ vi ~/.bash_profile
$ brew update
|
查看brew版本
安装软件
卸载软件
查看安装的软件列表
更新 brew