mac brew(homebrew) 配置和使用

细心整理,用心记录,谢谢大家阅读,请大家关注我,多多留言,cc 拜谢了

mac 软件管理软件,类似 ubuntu 的 apt,centos 的 yum

安装和换源到清华

0. 安装 xcode-select

sudo xcode-select --install

1. 安装,如果卡的话,可以在下面的 curl 中添加 --socks5 使用代理

/bin/bash -c "$(curl -fsSL https://github.com/Homebrew/install/raw/master/install.sh)"

2. 下面的添加到 ./zshrc,然后 source,清华还原网站上不是 zshrc,需要改一下

eval "$(/opt/homebrew/bin/brew shellenv)"
export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git"
export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git"
export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles"

3. 执行

for tap in core cask{,-fonts,-drivers,-versions} command-not-found; do
brew tap --custom-remote --force-auto-update "homebrew/${tap}" "https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-${tap}.git"
done

4. brew update 可能会先没有进度,需要多等待一会

对于原先是 intel 芯片然后迁移到 m1 上的用户,比如我,可以先进行步骤 1,
然后执行 brew bundle dump 进行迁移就完事了
参考 https://database.guide/fix-cannot-install-in-homebrew-on-arm-processor-in-intel-default-prefix-usr-local/

命令

基本命令

  • brew doctor 查看 brew 有什么问题,遇到什么问题都可以尝试下,然后自信 warning 中的建议命令
  • brew conifg 查看当前 brew 的配置
  • brew info nginx 查看 nginx 信息,可以查看安装位置,配置文件位置等
    也可以查看未安装的软件,得知版本号,即将安装到哪里等信息
  • brew search redis 查看有哪些 redis 可以安装
  • brew update 更新源
  • brew outdated --help 查看 brew outdated 的帮助信息

安装

  • brew install nginx 安装 nginx
  • brew reinstall nginx 重新安装 nginx
  • brew install --cask multipass --cask 参数通常是来安装带有 GUI 的软件,安装就是解压一个包,更加方便

查看

  • brew list --versions --cask 查看 cask 软件,并且同时列出版本
  • brew outdated --cask 查看过期的 cask 软件
  • brew deps logseq 查看软件 logseq 的依赖关系

更新

  • brew update 更新源
  • brew upgrade 更新软件,包含 formulae 和 cask
  • brew cu -facy 使用 buo/cask-upgrade tap 来进行更新所有 cask
  • -f 更新到最新
  • -a 自动更新
  • -y 全部选择 yes
  • -c 不知道

卸载删除

  • brew uninstall nginx 卸载 nginx
  • brew uninstall -f nginx 强制卸载 nginx,可能会导致其他软件不可用
彻底删除
  • brew tap beeftornado/rmtree
  • brew rmtree nginx 卸载并删除相关依赖
  • brew cleanup

安装位置

  • macOS Intel:/usr/local
  • Apple Silicon:/opt/homebrew
  • Linux:/home/linuxbrew/.linuxbrew

tap brew 的第三方管理工具

通过 brew tap 安装

  • beeftornado/rmtree 依赖删除工具,brew uninstall 的强化版
  • buo/cask-upgrade cask 升级工具,brew upgrade 对于 cask 的强化版
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

cctga

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值