介绍homebrew一些高级使用
Homebrew常规使用教程git
本身写了一个安装时的脚原本在安装时选择国内源:
github地址:https://github.com/rgf456/HomebrewInstall
基于官方脚本修改:github
1.启动iterm终端,输入如下命令:segmentfault
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/rgf456/HomebrewInstall/master/install.rb)"
此时会自动执行脚本,输出如下内容:缓存
~/ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/rgf456/HomebrewInstall/master/install.rb)" 请输入您要选择的源 0.HomeBrew官方镜像: brew: https://github.com/Homebrew/brew core: https://github.com/Homebrew/homebrew-core 1.清华大学镜像: brew: https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git core: https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git 2.中科大镜像: brew: https://mirrors.ustc.edu.cn/brew.git core: https://mirrors.ustc.edu.cn/homebrew-core.git -------------请输入0,1,2选择源地址--------------
2.选择对应的源编号,输入对应的数字,便可使用相应的源ruby
0 你选择的是官方镜像
请忽略警告bash
假如输入的不是0、一、2中的一个数字,则会提示默认选择官方安装.curl
3.官方流程fetch
==> This script will install: /usr/local/bin/brew /usr/local/share/doc/homebrew /usr/local/share/man/man1/brew.1 /usr/local/share/zsh/site-functions/_brew /usr/local/etc/bash_completion.d/brew /usr/local/Homebrew Press RETURN to continue or any other key to abort
点击enter等待安装完成url
安装完成后
执行命令行
cd "$(brew --repo)"
git remote -v
便可看到是否更换了镜像地址:
~/ cd "$(brew --repo)" /usr/local/Homebrew/ [stable] git remote -v origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git (fetch) origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git (push) rgf456 https://github.com/rgf456/brew (fetch) rgf456 https://github.com/rgf456/brew (push)
假如不想采用个人脚本安装,而是想本身指定的话:如下是手动替换清华镜像的官方教程,逐条命令行执行便可。
cd "$(brew --repo)" git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git 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
执行以下命令
brew --cache
通常状况下是以下路径~/Library/Caches/Homebrew
直接进入缓存路径
cd (brew --cache)
此时直接进入了缓存目录。
缓存目录可在安装时指定:(不建议)
首先下载安装脚本:
https://raw.githubusercontent...
将这个脚本内容保存至本地随便命名install
下载好install脚本后,找到HOMEBREW_CACHE变量,修改成本身想要的文件夹,而后执行安装命令:
/usr/bin/ruby -e "$(cat install)"
便可安装homebrew。
执行以下命令
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"