Homebrew能够简单理解为在Mac上用命令行安装软件的工具.git
brew install FORMULA...
.Formula
的快,也是默认的安装软件方式.配方Formula
,/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core
.配方
,/usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask
.系统版本: macOS Catalina 10.15.2github
1.安装Homebrew,目前官方最新版的安装方法已由原先的ruby脚本换成bash脚本了shell
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
2.使用国内镜像源swift
homebrew-core
仓库也克隆到了本地,那么只需更改本地brew
库(Homebrew软件自身)的homebrew-core
库的远程源地址便可# 简单比较过中科大的源和清华的源,前者更快,这里使用的是中科大提供的源 # 2.1 替换brew.git: cd "$(brew --repo)" git remote set-url origin https://mirrors.ustc.edu.cn/brew.git # 2.2 替换homebrew-core.git: cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core" git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git # 2.3 替换bottles源,macOS使用的是 zsh 的shell, 可执行`echo $0`查看当前的shell工具类型 echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.zshrc source ~/.zshrc
homebrew-core
仓库克隆失败的,须要手动克隆到本地:
即把上面一条中的2.2 替换homebrew-core.git
一步改为直接克隆到本地ruby
# shell执行 git clone https://mirrors.ustc.edu.cn/homebrew-core.git /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core
到这里Homebrew已经能够使用了.bash
3.cask源配置(选配,在安装图形界面软件时须要)
执行brew tap
查看下载到本地的仓库,若是 cask* 的都有则能够将其git的远程源替换成国内的curl
# shell执行 git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git git -C "$(brew --repo homebrew/cask-fonts)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask-fonts.git git -C "$(brew --repo homebrew/cask-drivers)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask-drivers.git
不然,直接将清华源的仓库克隆到本地工具
# shell执行 git clone https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask git clone https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask-fonts.git /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask-fonts git clone https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask-drivers.git /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask-drivers
# 搜索是否有这个软件 brew search wget # 安装 brew install wget
brew cask install atom
(上图来自官方git仓库中的readme)post
若有纰漏,欢迎留言补充.atom