文章目录

  • 前言
  • 一、Homebrew是什么?
  • 二、HomeBrew安装
  • 三、安装Git
  • 四、HomeBrew换源
    • 中科大(建议使用)
    • 阿里云
    • 清华
    • 腾讯
    • 初始默认镜像(国外源)
  • 五、HomeBrew基本使用命令
  • 六、HomeBrew卸载

前言

Homebrew 是一款包管理工具,目前支持 macOS 和 Linux 系统。主要有四个部分组成: brewhomebrew-corehomebrew-caskhomebrew-bottles

名称 说明
brew Homebrew 源代码仓库
homebrew-core Homebrew 核心源
homebrew-cask 提供 macOS 应用和大型二进制文件的安装
homebrew-bottles 预编译二进制软件包

一、Homebrew是什么?

Homebrew是一款Mac OS平台下的软件包管理工具,拥有安装、卸载、更新、查看、搜索等很多实用的功能。简单的一条指令,就可以实现包管理,而不用你关心各种依赖和文件路径的情况,十分方便快捷。

比如说,我们想要下载JDK,想要下载MySQL,需要去到各个官网进行下载
而 HomeBrew 类似于 Maven 一样,Maven管理着我们的依赖,而 Homebrew 里面存着我们开发需要用到的大部分套件,Homebrew —— OS X 不可或缺的套件管理器。

二、HomeBrew安装

/bin/bash -c "$(curl -fsSL https://cdn.jsdelivr.net/gh/ineo6/homebrew-install/install.sh)"

默认使用中科大源

最后看到 Installation successful! 就说明安装成功了。
还需要更换Homebrew Bottle源,这个只要在shell配置文件里加上(或更改)一个变量即可。
zsh就是编辑~/.zshrc文件, bash就是~/.bash_profile,一定要注意自己的SHELL的版本,否则配置了不生效

# 安装完成后设置
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles/bottles' >> ~/.zshrc
source ~/.zshrc

查看Homebrew的版本

zhouxucong ~ % brew --version
Homebrew 3.2.0
Homebrew/homebrew-core (git revision be99503861; last commit 2021-07-01)

三、安装Git

因为后续如果需要换源,需要用到 Git 相关命令,顺便体验下使用 HomeBrew 安装 Git

brew install git

直接使用这个命令,等待安装完成,完成后使用 git --version 查看安装版本

zhouxucong ~ % git --version
git version 2.14.1

四、HomeBrew换源

根据shell的版本,zsh就是编辑~/.zshrc文件, bash就是~/.bash_profile,一定要注意自己的SHELL的版本,否则配置了不生效

中科大(建议使用)

# 脚本
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
brew updateecho 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles/bottles' >> ~/.zshrc
source ~/.zshrc

阿里云

# 替换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
# 应用生效
brew update
# 替换homebrew-bottles:
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.zshrc
source ~/.zshrc

清华

# 脚本
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 updateecho 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/bottles' >> ~/.zshrc
source ~/.zshrc

腾讯

# 脚本
git -C "$(brew --repo)" remote set-url origin https://mirrors.cloud.tencent.com/homebrew/brew.git
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.cloud.tencent.com/homebrew/homebrew-core.git
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.cloud.tencent.com/homebrew/homebrew-cask.git
brew updateecho 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.cloud.tencent.com/homebrew-bottles/bottles' >> ~/.zshrc
source ~/.zshrc

初始默认镜像(国外源)

# 脚本
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

homebrew-bottles配置只能手动删除,将 ~/.zshrc 文件中的 HOMEBREW_BOTTLE_DOMAIN=https://mirrors.xxx.com内容删除,并执行 source ~/.zshrc

可以通过 brew config 查看当前正在使用

zhouxucong ~ % brew config
HOMEBREW_VERSION: 3.2.0
ORIGIN: https://mirrors.ustc.edu.cn/brew.git
HEAD: 09f7bc27a99469cf947431df4754737dfbadb31d
Last commit: 2 months ago
Core tap ORIGIN: https://mirrors.ustc.edu.cn/homebrew-core.git
Core tap HEAD: be9950386188986fb14fea4fbabe5378df0a1013
Core tap last commit: 9 weeks ago
Core tap branch: master
HOMEBREW_PREFIX: /usr/local
HOMEBREW_BOTTLE_DOMAIN: https://mirrors.ustc.edu.cn/homebrew-bottles/bottles
HOMEBREW_CASK_OPTS: []
HOMEBREW_MAKE_JOBS: 12
Homebrew Ruby: 2.6.3 => /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.3_2/bin/ruby
CPU: dodeca-core 64-bit kabylake
Clang: 12.0.0 build 1200
Git: 2.14.1 => /usr/local/bin/git
Curl: 7.64.1 => /usr/bin/curl
macOS: 10.15.7-x86_64
CLT: 12.4.0.0.1.1610135815
Xcode: N/A

五、HomeBrew基本使用命令

查看brew的帮助

brew –help

搜索软件

brew search [软件名]

安装软件

brew install [软件名]

卸载软件

brew uninstall [软件名]

显示已经安装软件列表

brew list

更新某具体软件

brew upgrade [软件名]

暂时了解这么多足够了

六、HomeBrew卸载

/bin/bash -c "$(curl -fsSL https://cdn.jsdelivr.net/gh/ineo6/homebrew-install/uninstall.sh)"

然后删掉 HOMEBREW_BOTTLE_DOMAIN 环境变量,将你终端文件 ~/.bash_profile或者 ~/.zshrc

HOMEBREW_BOTTLE_DOMAIN 删除

source ~/.bash_profile
或者
source ~/.zshrc

Homebrew介绍和使用相关推荐

  1. mac 查看环境变量_Mac开工利器Homebrew介绍

    前言 最近好多测试小伙伴悄然换上了MAC,下面介绍一款攻城狮们macOS下都在用的神器-Homebrew. 一.Homebrew简介 Homebrew是一款Mac OS平台下的软件包管理工具,拥有安装 ...

  2. 【Homebrew】Homebrew 介绍与安装

    目录 一. 介绍 1.1 啥是 Homebrew 呢? 1.2 Homebrew 能干啥 ? 1.3 Homebrew 简单命令 二. 安装 2.1 WSL 安装 2.2 切换源 2.3 配置环境变量 ...

  3. homebrew介绍

    1 Homebrew 概述   brew 又叫Homebrew,是Mac OSX上的软件包管理工具,能在Mac中方便的安装软件或者卸载软件,类似ubuntu系统下的apt-get的功能.   home ...

  4. [note] Homebrew的介绍、安装方法与常用命令整理

    Homebrew介绍: Homebrew是Mac下一款软件包管理器(软件包管理系统:在计算机中自动安装.配置.卸载和升级软件包的工具组合),可以简化macOS上软件的安装管理过程.Homebrew C ...

  5. MacOS安装Homebrew与Oh-My-Zsh

    写在前面:博主是一只经过实战开发历练后投身培训事业的"小山猪",昵称取自动画片<狮子王>中的"彭彭",总是以乐观.积极的心态对待周边的事物.本人的技 ...

  6. Homebrew是什么?以及使用

    一.Homebrew是什么?Homebrew的安装和使用 Homebrew是一款Mac OS平台下的软件包管理工具,拥有安装.卸载.更新.查看.搜索等很多实用的功能.简单的一条指令,就可以实现包管理, ...

  7. Homebrew安装与配置

    文章目录 一. Homebrew介绍 二. 安装Homebrew 三. 更换镜像 四. Brew命令 一. Homebrew介绍 Homebrew是一款macOS(或 Linux)软件包的管理工具.主 ...

  8. 【iOS工具】rvm、Ruby环境和CocoaPods安装使用及相关报错问题解决(2016 12 15 更新)...

    〇.前言 在iOS开发中 [CocoaPods](https://github.com/CocoaPods/CocoaPods) 作为库依赖管理工具就是一把利器. 有了 CocoaPods 则无需再通 ...

  9. mac下安装nginx和php

    From: http://www.jb51.net/article/42715.htm mac下使用homebrew安装安装.配置nginx.mysql.php-fpm的方法. 一.前话: 1.1.环 ...

最新文章

  1. XMPP iOS客户端实现三:登录、注册
  2. html实现旅游网站代码_[资源推荐] 必须收藏的两个查找论文和代码实现的网站!...
  3. Echarts多个坐标轴多组/一组数据 - 温度降水量示例
  4. 64位处理器_快看看你的电脑是64位还是32位操作系统,处理器支持64位可升级
  5. TypeScript泛型约束
  6. mongodb和mysql空间占用_MongoDB的存储结构及对空间使用率的影响
  7. ******“伪装”七夕传情网页
  8. 很恶心的一个关于字符串的题目!
  9. C语言字符型数据scanf,scanf()函数如何输入字符型数据?
  10. java冒泡排序算法代码降序_Java排序算法总结之冒泡排序
  11. 西门子s1200教程_西门子S-1200入门PLC视频教程百度云资源下载
  12. 图论及其应用 2018年期末考试 答案总结
  13. 二叉树非递归遍历(c语言)
  14. 前端上半年工作总结、下半年工作计划
  15. Chrome浏览器通过chrono下载插件设置下载断点续传
  16. less 或 scss 覆盖UI组件样式并集选择器使用
  17. 来势汹汹,奥米克戎;是否补种,特定疫苗? | 经济学人全球早报精选
  18. 基于SSH的员工信息管理系统
  19. 如何在微信小程序里面退出小程序
  20. iOS-百度语音识别

热门文章

  1. OrmLite框架 —— OrmLite 入门使用(一)
  2. 输出第一行1个 *,第二行 3个*.....
  3. 没有压力就不会有动力.
  4. 金三银四跳槽的正确姿势你掌握了么?
  5. powershell运行cmd命令时出错The token ‘‘ is not a valid statement separator in this version.
  6. 6、 函数模板和类模板
  7. 阿里企业邮箱服务器地址(IMAP、POP、SMTP)
  8. 企业网站产品页面优化技巧
  9. 天地图一,加载天地图。
  10. 找规律:2,10,30,68,130,()