homebrew簡單的介紹與使用
homebrew能幹什麼
使用 Homebrew 安裝 mac osx(或您的 Linux 系統)沒有預裝但你需要的軟件;類似於ubuntu的apt-get、centos的yum。
官網:https://brew.sh/
官方說明:
Homebrew 會將軟件包安裝到獨立目錄,並將其文件軟鏈接至 /usr/local
Homebrew 不會將文件安裝到它本身目錄之外,所以您可將 Homebrew 安裝到任意位置。
完全基於 Git 和 Ruby,所以自由修改的同時你仍可以輕鬆撤銷你的變更或與上游更新合併。
homebrew的安裝
輸入命令:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
homebrew的卸載
將install換位uninstall就行了:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
homebrew的基本命令
1、安裝軟件包
brew install PackageName
2、卸載軟件包
brew uninstall PackageName
3、查詢可用安裝包
brew search PackageName
4、列出已安裝包
brew list
5、更新安裝包
brew upgrade
6、更新homebrew
brew update
7、Homebrew常用命令
brew -v 查詢Homebrew版本
brew -h brew幫助
brew update 更新Homebrew
brew install <pkg_name> 安裝任意軟件
brew uninstall <pkg_name> 卸載任意軟件
brew search <pkg_name> 查詢任意包
brew list 列出安裝列表
brew info <pkg_name> 查看任意包內容信息
brew upgrade <pkg_name> 更新任意包
brew cleanup <pkg_name> 刪除具體舊軟件
brew cleanup 刪除所有舊軟件
brew outdated 已安裝的包是否需要更新
brew deps 已安裝的包是否需要更新
homebrew 更新國內源
1、中科大源
替換brew.git:
cd "$(brew --repo)"
git remote set-url origin https://mirrors.ustc.edu.cn/brew.git
替換homebrew-core.git:
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
替換Homebrew Bottles
源:
對於bash用戶
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile
對於zsh用戶
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.zshrc
source ~/.zshrc
中科大源地址:
官方地址
2、清華源
替換現有上游
git -C "$(brew --repo)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
git -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
brew update
復原
git -C "$(brew --repo)" remote set-url origin https://github.com/Homebrew/brew.git
git -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
brew update
清華源地址:
官方地址
3、阿里雲源
替換brew.git:
cd "$(brew --repo)"
git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git
替換homebrew-core.git:
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git
替換homebrew-bottles:
brew update
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile