Mac软件包管理

Mac下有两种软件,一种是像word,PS等应用软件,这种软件可以自行下载安装包,或者通过应用商店安装即可。还有一种是程序员用得比较多的软件包,像git,nodejs等,这种软件建议使用homebrew来统一安装。

安装homebrew

引用官方的一句话:Homebrew是Mac OS 不可或缺的套件管理器。

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

  • 安装homebrew命令
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  • 安装homebrew命令(国内地址)
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
  • 卸载homebrew命令
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"

由于访问国外很慢,所以需要替换镜像源,依次执行下面命令

替换各个源

$ 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

# zsh 替换 brew bintray 镜像
$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.zshrc
$ source ~/.zshrc

# bash 替换 brew bintray 镜像
$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.bash_profile
$ source ~/.bash_profile

# 刷新源
$ brew update

homebrew命令参考

  • 更新homebrew
    brew update
  • 更新所有安装过的软件包
    brew upgrade
  • 更新指定的软件包
    brew upgrade git
  • 查找软件包
    brew search git
  • 安装软件包
    brew install git
  • 卸载软件包
    brew remove git
  • 列出已安装的软件包
    brew list
  • 查看软件包信息
    brew info git
  • 列出软件包的依赖关系
    brew deps git
  • 列出可以更新的软件包
    brew outdated
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。