Homebrew详解

2019-01-12  本文已影响32人  奶爸撸代码

[TOC]

简介

安装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

# 更新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

上一篇 下一篇

猜你喜欢

热点阅读