[TOC]
简介
- Homebrew是Mac OSX常见的包管理器(命令brew用于命令行工具, brew cask管理带UI软件), 类似 ubuntu下apt-get, centOS的yum. 推荐日常Mac下安装卸载软件使用.
- 官网
- 基于Ruby的开源工具 github
安装Homebrew
安装
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
国内源
其实是替换brew/homebrew-core的git远端仓库(需要安装git), 替换二进制编译包环境变量(homebrew-bottles), 参考清华源
# 替换brew.git
cd "$(brew --repo)"
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
# 替换homebrew-core
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
# 更新
brew update
# 替换二进制预编译包
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile
# 或临时替换
export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles
使用Homebrew
- 帮助信息:
brew help(-h)
- 基本使用
# 更新Homebrew本身, formulae索引等, 需要先安装git
brew update
# 安装应用, 例如wget, 安装到/usr/local/Cellar/wget, ln到/usr/local/bin目录下
brew install wget
# 安装带UI app, 插件, 字体(fonts)及其他非开源应用
brew cask install firefox
# 更新app
brew upgrade git
# 诊断依赖冲突等
brew doctor
# 搜索app
brew search xxx
# 卸载xxx.app
brew uninstall xxx
# 列出安装的包
brew list
- 其他命令
# 打开包主页
brew home git
# 查看包信息
brew ino git
# 查看包依赖
brew deps wget #结果显示gettext libidn2 libunistring openssl
# 清理旧版本
brew cleanup git
brew cleanup
# 显示是否有新版本可用
brew outdated
# 再来个卸载
brew rm wget # uninstall wget
brew remove -h
卸载Homebrew
cd `brew –prefix`
rm -rf Cellar
brew cleanup
rm -rf Homebrew
rm -rf ~/Library/Caches/Homebrew
如此神器, 你舍得卸载吗? 我是没卸载过, 以上卸载步骤仅供参考~~~
Formula
formula: 应用安装包相关的Ruby脚本文件, 定义Homebrew软件包, 参考formula
Homebrew formulae are simple Ruby scripts
-- from brew.sh
- 可以自定义formula, see formula cookbook
网友评论