当前位置: 首页 > news >正文

【Mac】Homebrew

1、Homebrew 简介

官网地址:https://brew.sh

Homebrew 是一款Mac OS平台下的软件包管理工具,拥有安装、卸载、更新、查看、搜索等很多实用的功能。

Homebrew 主要有四个部分组成: brew、homebrew-core 、homebrew-bottles、homebrew-cask。

说明
brewHomebrew 源代码仓库
homebrew-coreHomebrew 核心软件仓库
homebrew-bottlesHomebrew 预编译二进制软件包
homebrew-cask提供 macOS 应用和大型二进制文件

2、安装 Homebrew

下边三种命令任选一条命令执行即可:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)
source /Users/rzm/.zprofile

3、卸载 Homebrew

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"

4、Homebrew 命令

命令说明
brew -v查看版本
brew -h查看帮助信息
brew help查看帮助信息
brew list列出已安装的软件包
brew update更新 homebrew
brew outdated列出可以更新的软件包
brew upgrade更新所有安装过的软件包
brew upgrade git更新指定的软件包
brew search git查找软件包
brew install git安装软件包
brew remove git卸载软件包
brew info git查看软件包信息
brew deps git列出软件包的依赖关系

5、修改 Homebrew 源

5.1 阿里源

# 查看 brew.git 当前源
$ cd "$(brew --repo)" && git remote -v
origin    https://github.com/Homebrew/brew.git (fetch)
origin    https://github.com/Homebrew/brew.git (push)# 查看 homebrew-core.git 当前源
$ 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)# 修改 brew.git 为阿里源
$ git -C "$(brew --repo)" remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git# 修改 homebrew-core.git 为阿里源
$ git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git# zsh 替换 brew bintray 镜像
$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.zshrc
$ source ~/.zshrc# bash 替换 brew bintray 镜像
$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.bash_profile
$ source ~/.bash_profile# 刷新源
$ brew update

5.2 清华源

# 替换各个源
$ 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# zsh 替换 brew bintray 镜像
$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.zshrc
$ source ~/.zshrc# bash 替换 brew bintray 镜像
$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.bash_profile
$ source ~/.bash_profile# 刷新源
$ brew update

5.3 中科大源

# 替换各个源
$ 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# zsh 替换 brew bintray 镜像
$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.zshrc
$ source ~/.zshrc# bash 替换 brew bintray 镜像
$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
$ source ~/.bash_profile# 刷新源
$ brew update

5.4 官方源(重置)

# 重置 brew.git 为官方源
$ git -C "$(brew --repo)" remote set-url origin https://github.com/Homebrew/brew.git# 重置 homebrew-core.git 为官方源
$ git -C "$(brew --repo homebrew/core)" remote set-url origin https://github.com/Homebrew/homebrew-core.git# 重置 homebrew-cask.git 为官方源
$ git -C "$(brew --repo homebrew/cask)" remote set-url origin https://github.com/Homebrew/homebrew-cask# zsh 注释掉 HOMEBREW_BOTTLE_DOMAIN 配置,其实就是加个#,也可用nano
$ vi ~/.zshrc
# export HOMEBREW_BOTTLE_DOMAIN=xxxxxxxxx# bash 注释掉 HOMEBREW_BOTTLE_DOMAIN 配置,其实就是加个#,也可用nano
$ vi ~/.bash_profile
# export HOMEBREW_BOTTLE_DOMAIN=xxxxxxxxx# 刷新源
$ brew update

10、参考资料

  • Mac 下 brew 源切换
  • Mac软件包管理
http://www.lryc.cn/news/475069.html

相关文章:

  • Python笔记之线程库threading
  • go 包管理
  • Js内建对象
  • AXI接口的实现逻辑和底层原理,在FPGA中如何实现AXI接口,一篇文章足以搞明白!!!
  • 《GBDT 算法的原理推导》 11-12计算损失函数的负梯度 公式解析
  • mysql设计
  • Android 斗鱼面经
  • 【机器学习】26. 聚类评估方法
  • linux 最多能创建多少个 TCP 连接?
  • 我为何要用wordpress搭建一个自己的独立博客
  • Linux系统每日定时备份mysql数据
  • 书生大模型第一关Linux基础知识
  • 机器学习之fetch_olivetti_faces人脸识别--基于Python实现
  • 【系统设计】深入理解HTTP缓存机制:从Read-Through缓存到HTTP缓存的交互流程
  • FLINK单机版安装部署入门-1
  • 深度学习-学习率调整策略
  • 【学员提问bug】小程序在onUnload里面调接口,用来记录退出的时间, 但是接口调用还没成功, 页面就关闭了。如何让接口在onUnload关闭前调用成功?
  • 【刷题13】链表专题
  • Python Turtle模块详解与使用教程
  • 【PTA】4-2 树的同构【数据结构】
  • Node.js——fs模块-同步与异步
  • Java基于微信小程序的私家车位共享系统(附源码,文档)
  • vscode 创建 vue 项目时,配置文件为什么收缩到一起展示了?
  • PySpark任务提交
  • 【果蔬购物商城管理与推荐系统】Python+Django网页界面+协同过滤推荐算法+管理系统网站
  • 【大模型】海外生成式AI赛道的关键玩家:OpenAI、Anthropic之外还有谁?
  • kubevirt cloud-init配置
  • Oracle 大表添加索引的最佳方式
  • 速度了解云原生后端!!!
  • 云计算Openstack 虚拟机调度策略