mac安装brew及修改brew源

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

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

Mac 卸载重装 brew

1.卸载 brew

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

2.卸载之后重新安装

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

3.安装完成之后,输入

brew update

会提示是最新版本,不需要更新

在2019年2月之后brew的有的安装服务是不可用的,brew公司认为有许多服务需要开发者编译,对开发者不友好,所以取消了很多的命令,网上的之前的一些命令都是过时的,所以在安装很多服务的时候需要先使用

brew search 服务名称

进行查找,如果有在进行安装否则会提示 找不到服务

4.brew 常用命令
更新 brew update
查找 brew search 服务名称
安装 brew install 服务名称
更新 brew update

安装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

 

posted @ 2021-01-06 10:22  coocoo  阅读(2724)  评论(0编辑  收藏  举报