获取 Homebrew
1.打开终端
2.复制粘贴下面代码
获取homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" ```
**卸载homebrew**
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
3.输入命令后会出现如下提示,回车继续安装,提示输入电脑密码是输入,好了直到安装完毕。
## homebrew使用
* 查看版本:brew -v
* 下载软件:brew install 软件名
如:brew install htop , 安装htop;
==如需要图形安装的软件 要加*cask*:
` brew install caskroom/cask/brew-cask(brew install cask) `
如:` brew cask install google-chrome`
* 卸载软件:brew uninstall 软件名
如: `brew cask uninstall google-chrome `, 卸载chrome浏览器;
* 软件搜索:brew search 软件名
如: brew search google
==支持*正则表达式*:` brew search /^vi/`(搜索以vi开头的软件)
* 列出已安装的包:` brew list`
* 列出过时的包:`brew outdated `
* 查看软件相关信息:brew info 软件名
如:` brew info google-chrome `
* 删除 Homebrew下载的包:` brew cleanup `
* 更新 Homebrew:` brew update`
## homebrew 扩展使用
### mac命令自动补全
1.安装bash-completion:` brew install completion `
2.` brew info bash-completion `显示结果复制最后两行:
Add the following lines to your ~/.bash_profile:
[ -f /usr/local/etc/bash_completion ] && . /usr/local/etc/bash_completion
3.创建.bash_profile:` touch .bash_profile `
4.编辑.bash_profile:` vim .bash_profile `把刚刚复制的粘贴进去,保存退出
### 安装ZSH的插件 oh-my-zsh
1.下载 : git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh( 安装 oh-my-zsh 时,它自动读取你的环境变量并且自动帮 zsh 进行设置.)
2.替换zshrc : cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
3.bash 切换成zsh:chsh -s /bin/zsh
zsh 切换成bash:chsh -s /bin/bash
### oh-my-zsh iterm2的配色方案
1.下载:` git clone git://github.com/altercation/solarized.git `
2.前往solarized(你下载的在哪里),我的在 ~/solarized/iterm2-colors-solarized
3.打开iterm2>profiles>open profiles>edit profiles
4.点击profiles>colors> 右下角import导入刚刚在哪文件找到的主题
⁃ 5.在点击text,Text Rendering下的raw bold text in bright colors前面的勾去掉
6.重启颜色方案生效
## homebrew扩展仓库
* 列出已有仓库:` brew tap`
* 添加仓库:` brew tap 仓库名 `
* 删除仓库:` brew untap 仓库名`
## homebrew更新源
### git仓库源
cd /usr/local/Homebrew
git remote set-url origin http://mirrors.ustc.edu.cn/homebrew.git
cd ~
mkdir tmp
cd tmp
git clone http://mirrors.ustc.edu.cn/homebrew.git
cp -R homebrew/.git /usr/local/Homebrew
cp -R homebrew/Library /usr/local/Homebrew
### 服务器地址源
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.zshrc
source ~/.zshrc