Mac 下安装 HomeBrew
技.技术研究96 阅读约 5 分钟
Mac 下安装 HomeBrew与使用
前置知识
HomeBrew 是什么
Homebrew 是一款 Mac OS 平台下的软件包管理工具,拥有安装、卸载、更新、查看、搜索等很多实用的功能。简单的一条指令,就可以实现包管理,而不用你关心各种依赖和文件路径的情况,十分方便快捷。
HomeBrew 安装
安装(国外官方源)
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
换源(中科大源)
# 修改 brew.git
cd "$(brew --repo)" && git remote set-url origin https://mirrors.ustc.edu.cn/brew.git
# 修改 homebrew-core.git
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core" && git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
# 修改 homebrew-bottles
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile && source ~/.bash_profile
# 立刻生效
brew update
# 查看(诊断) brew 状态
brew doctor
# 重置 brew.git
cd "$(brew --repo)" && git fetch && git reset --hard origin/master
# 切回官方 brew.git
cd "$(brew --repo)" && git remote set-url origin https://github.com/Homebrew/brew.git
# 重置 homebrew-core.git
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core" && git fetch && git reset --hard origin/master
# 切回官方 homebrew-core.git
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core" && git remote set-url origin https://github.com/Homebrew/homebrew-core.git
# 立刻生效
brew update
卸载
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall.sh)"
如国无法安装或者安装缓慢,可以使用国内源(强烈建议)
建议: 中科大源
安装
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
卸载
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/HomebrewUninstall.sh)"
brew 常用命令
- 查看版本:brew -v
- 安装软件:brew install 软件名
- 搜索软件:brew search 软件名
- 卸载软件:brew uninstall 软件名
- 更新所有软件:brew update
- 更新具体软件:brew upgrade 软件名
- 显示已安装软件:brew list
- 查看哪些已安装的程序需要更新: brew outdated
- 显示包依赖:brew reps
- 显示帮助:brew help
- 显示软件信息:brew info
- 打开软件网站:brew home
- 打开软件网站:brew home
- 显示 brew 配置:brew config
相关文章
评论 (0)
还没有评论,来抢沙发
