mac安装brew及修改brew源

brew 又叫Homebrew,是Mac OSX上的软件包管理工具,能在Mac中方便的安装软件或者卸载软件, 只需要一个命令, 非常方便

brew类似ubuntu系统下的apt-get的功能

安装brew

brew 的官方网站: http://brew.sh/   在官方网站对brew的用法进行了详细的描述

安装方法:  在Mac中打开Termal:  输入命令:

# ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

使用brew安装软件

一个命令就搞定了

安装git
# brew install git
安装wget
# brew install wget
使用brew卸载软件
# brew uninstall wget
使用brew查询软件
比如查询wget
# brew search /wge*/  : /wge*/是个正则表达式, 需要包含在/中
其他brew命令
# brew list       //列出已安装的软件
# brew update     //更新brew
# brew home       //用浏览器打开brew的官方网站
# brew info       //显示软件信息
# brew deps       //显示包依赖

brew源改成清华的源

# git -C "$(brew --repo)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
# git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
# git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git
# brew update

brew源改成aliyun的源

# git -C "$(brew --repo)" remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git
# git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git
# git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.aliyun.com/git/homebrew/homebrew-cask.git # brew update

如果想还原brew源

# 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.git
# brew update
原文地址:https://www.cnblogs.com/ckh2014/p/14239573.html