獲取 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