Homebrew 安裝及基本使用

Homebrew 是 Mac OSX 上的軟體包管理工具,能在 Mac 中方便的安裝軟體或者解除安裝軟體,相當於 Linux 下的 apt-get、yum 神器;Homebre 可以在 Mac 上安裝一些 OS X 沒有的 UNIX 工具,Homebrew 將這些工具統統安裝到了 /usr/local/Cellar 目錄中,並在 /usr/local/bin 中建立符號連結。 官網地址:brew。sh/index_zh-cn…

安裝

在終端裡執行以下命令

/usr/bin/ruby -e “$(curl -fsSL https://raw。githubusercontent。com/Homebrew/install/master/install)”複製程式碼

安裝完成以後,需要執行brew doctor命令檢測下是否有什麼衝突的地方,如果有可以按照提示處理

Homebrew 安裝成功後,會自動建立目錄/usr/local/Cellar來存放 Homebrew 安裝的程式

基本使用

# 搜尋包brew search mysql# 安裝包brew install mysql# 檢視包資訊,比如目前的版本,依賴,安裝後注意事項等brew info mysql# 解除安裝包brew uninstall wget# 顯示已安裝的包brew list# 檢視brew的幫助brew –help# 更新, 這會更新 Homebrew 自己brew update# 檢查過時(是否有新版本),這會列出所有安裝的包裡,哪些可以升級brew outdatedbrew outdated mysql# 升級所有可以升級的軟體們brew upgradebrew upgrade mysql# 清理不需要的版本極其安裝包快取brew cleanupbrew cleanup mysql複製程式碼

配置映象

使用 清華映象站點 的映象

配置索引映象

git -C “$(brew ——repo)” remote set-url origin https://mirrors。tuna。tsinghua。edu。cn/git/homebrew/brew。gitgit -C “$(brew ——repo homebrew/core)” remote set-url origin https://mirrors。tuna。tsinghua。edu。cn/git/homebrew/homebrew-core。git# git -C “$(brew ——repo homebrew/cask)” remote set-url origin https://mirrors。tuna。tsinghua。edu。cn/git/homebrew/homebrew-cask。git# git -C “$(brew ——repo homebrew/cask-fonts)” remote set-url origin https://mirrors。tuna。tsinghua。edu。cn/git/homebrew/homebrew-cask-fonts。git# git -C “$(brew ——repo homebrew/cask-drivers)” remote set-url origin https://mirrors。tuna。tsinghua。edu。cn/git/homebrew/homebrew-cask-drivers。git# 更換後測試工作是否正常brew update複製程式碼

復原索引映象

git -C “$(brew ——repo)” remote set-url origin https://github。com/Homebrew/brew。gitgit -C “$(brew ——repo homebrew/core)” remote set-url origin https://github。com/Homebrew/homebrew-core。git# git -C “$(brew ——repo homebrew/cask)” remote set-url origin https://github。com/Homebrew/homebrew-cask。git# git -C “$(brew ——repo homebrew/cask-fonts)” remote set-url origin https://github。com/Homebrew/homebrew-cask-fonts。git# git -C “$(brew ——repo homebrew/cask-drivers)” remote set-url origin https://github。com/Homebrew/homebrew-cask-drivers。git# 更換後測試工作是否正常brew update複製程式碼

配置二進位制預編譯包映象

export HOMEBREW_BOTTLE_DOMAIN=https://mirrors。tuna。tsinghua。edu。cn/homebrew-bottles