当前位置:   article > 正文

最全Homebrew使用或配置方法_homebrew 完整 教程

homebrew 完整 教程

一、Homebrew是什么?

下文中所有命令,均在2.5.6-132-gde8f487版本验证通过。

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

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

二、安装与卸载

# 安装
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# 卸载
/bin/bash -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
# 自升级
brew upgrade brew
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

三、换源

  • 第一步,替换brew.git

    cd "$(brew --repo)"
    git remote set-url origin https://mirrors.ustc.edu.cn/brew.git
    
    • 1
    • 2
  • 第二步:替换homebrew-core.git

    cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
    git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
    
    • 1
    • 2
  • 替换homebrew-cask默认源

    cd "$(brew --repo)/Library/Taps/homebrew/homebrew-cask"
    git remote set-url origin git://mirrors.ustc.edu.cn/homebrew-cask.git
    
    • 1
    • 2
  • 替换homebrew-bottle默认源

    echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
    source ~/.bash_profile
    
    • 1
    • 2

附清华大学源

https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
  • 1
  • 2

四、Homebrew的一般使用方法

命令说明
brew help查看帮助
brew search 软件名搜索软件
brew info 软件名查询指定软件信息
brew install 软件名安装软件
brew install 软件名@版本号安装指定版本的软件(安装前可先search有哪些版本)
brew outdated检查哪些软件可更新
brew update升级所有软件
brew upgrade 软件名升级指定软件
brew uninstall 软件名卸载软件
brew cleanup清除所有软件的旧版本
brew cleanup 软件名清除指定软件的旧版本
brew cleanup -n查看可清理的旧版本的软件,不做实际清除操作
brew pin 软件名锁定指定软件,保证在全局更新时不更新
brew unpin 软件名取消锁定指定软件
brew list查询已安装的软件信息
brew deps --installed --tree查看已安装软件的依赖,以树形展示
brew config查看Homebrew配置
brew services start|stop|restart 软件名启动/停止/重启Homebrew服务

五、软件安装路径

  • 默认安装路径:/usr/local/Cellar/

  • 如需修改,则修改config中的HOMEBREW_PREFIX参数(默认为/usr/local)。个人建议不要修改,因为凡自己安装的软件大部分都放在这个目录下,保证安装路径统一。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/盐析白兔/article/detail/760468
推荐阅读
相关标签
  

闽ICP备14008679号