Homebrew,OS X 不可或缺的套件管理器。类似于Debian系列的apt-get,Redhat的yum,主要用来安装一些开源软件,这些工具的存在大大简化了开源软件的安装过程。
下面的内容其实官网都有,简单汇总下。更多内容请访问上面的站点。
Homebrew通过以下命令安装即可:
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
Homebrew通过以下命令卸载:
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/HomebrewUninstall.sh)"
这里以colordiff的安装为例介绍:
brew search colordiff
brew install colordiff
brew uninstall colordiff
brew list
brew update
brew cleanup
brew cleanup $FORMULA
brew cleanup -n
对于以下需要添加代理的网络,只需要直接配置shell的代理即可,事例如下:
export http_proxy='http://127.0.0.1:8080';
export https_proxy='http://127.0.0.1: 8080'
export no_proxy="127.0.0.1|localhost"
使用以下命令更换国内阿里云上的homebrew镜像:
# 替换brew.git:
cd "$(brew --repo)"
git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git
# 替换homebrew-core.git:
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git
# 替换homebrew-bottles:
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.zshrc
source ~/.zshrc
切换到官网默认:
重置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