技术文摘
MacOS 中 Homebrew 的安装、配置、国内镜像源更改与使用全解
MacOS 中 Homebrew 的安装、配置、国内镜像源更改与使用全解
在 MacOS 系统中,Homebrew 是一款强大且实用的包管理工具,它为用户提供了便捷的软件安装和管理方式。下面将为您详细介绍 Homebrew 的安装、配置、国内镜像源更改以及使用方法。
一、安装 Homebrew
首先,打开终端应用程序。然后,在终端中输入以下命令:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
按照提示进行操作,等待安装完成。
二、配置 Homebrew
安装完成后,建议对 Homebrew 进行一些基本的配置。例如,可以设置 Homebrew 安装软件的默认路径等。
三、更改国内镜像源
由于某些原因,可能访问官方源的速度较慢。这时,我们可以更改国内镜像源来提高下载速度。以下是常见的国内镜像源:
- 中科大镜像源
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
- 清华镜像源
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
四、使用 Homebrew
安装软件非常简单,只需要在终端中输入 brew install 软件名 即可。例如,要安装 Python ,可以输入 brew install python 。
查询已安装的软件可以使用 brew list 命令。
更新 Homebrew 本身可以使用 brew update 命令。
卸载软件则使用 brew uninstall 软件名 命令。
总之,Homebrew 为 MacOS 用户提供了极大的便利,通过合理的安装、配置、更改镜像源和使用,能够让您更加高效地管理和使用软件。
TAGS: MacOS 中 Homebrew 安装 MacOS 中 Homebrew 配置 MacOS 中 Homebrew 使用