簡(jiǎn)介
Homebrew官網(wǎng):http://brew.sh/index_zh-cn.html
Homebrew是Mac OSX上的軟件包管理工具舀瓢,能在Mac中方便的安裝軟件或者卸載軟件抡秆,相當(dāng)于linux下的apt-get坊夫、yum神器;Homebre可以在Mac上安裝一些OS X沒(méi)有的UNIX工具,Homebrew將這些工具統(tǒng)統(tǒng)安裝到了 /usr/local/Cellar 目錄中,并在 /usr/local/bin 中創(chuàng)建符號(hào)鏈接怯屉。
Homebrew的安裝
Homebrew的安裝很簡(jiǎn)單,只需在終端下輸入如下指令:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
打開(kāi)終端窗口, 粘貼以上腳本饵沧。
==> This script will install:
/usr/local/bin/brew
.....中間省略
==> The following directories will be made group writable:
/usr/local/.
/usr/local/bin
....中間省略
==> The following directories will have their owner set to zh:
/usr/local/.
/usr/local/bin
......中間省略
==> The following directories will have their group set to admin:
/usr/local/.
/usr/local/bin
......中間省略
Press RETURN to continue or any other key to abort
==> /usr/bin/sudo /bin/chmod g+rwx /usr/local/. /usr/local/bin /usr/local/share/usr/local/share/man /usr/local/share/man/man1 /usr/local/share/man/man3 /usr/local/share/man/man5 /usr/local/share/man/man7
==> Installation successful!
==> Next steps
Run `brew help` to get started
Further documentation: https://git.io/brew-docs
==> Homebrew has enabled anonymous aggregate user behaviour analytics
Read the analytics documentation (and how to opt-out) here: https://git.io/brew-analytics
腳本會(huì)解釋它的作用锨络,然后在您的確認(rèn)下執(zhí)行安裝。高級(jí)安裝選項(xiàng)請(qǐng)看 這里(需要10.5)捷泞。
Homebrew能干什么足删?
又提示缺少套件啦?別擔(dān)心锁右,Homebrew 隨時(shí)守候。
$ brew install wget
Homebrew 會(huì)將套件安裝到獨(dú)立目錄讶泰,并將文件軟鏈接至/usr/local咏瑟。
$ cd /usr/local$ find CellarCellar/wget/1.16.1Cellar/wget/1.16.1/bin/wgetCellar/wget/1.16.1/share/man/man1/wget.1$ ls -l binbin/wget -> ../Cellar/wget/1.16.1/bin/wget
Homebrew 的所有文件均會(huì)被安裝到預(yù)定義目錄下,所以您無(wú)需擔(dān)心 Homebrew 的安裝位置痪署。
輕松創(chuàng)建您的 Homebrew 程式码泞。
$ brew create https://foo.com/bar-1.0.tgzCreated /usr/local/Library/Formula/bar.rb
以 git、 ruby 為其筋骨狼犯,所以借助您的相關(guān)知識(shí)余寥,自由修改,并且可以簡(jiǎn)單撤回您的調(diào)改或者合并上游更新悯森。
$ brew edit wget # 使用 $EDITOR 編輯!
Homebrew 的程式都是簡(jiǎn)單的 Ruby 腳本:
class Wget < Formula homepage "https://www.gnu.org/software/wget/" url "https://ftp.gnu.org/gnu/wget/wget-1.15.tar.gz" sha256 "52126be8cf1bddd7536886e74c053ad7d0ed2aa89b4b630f76785bac21695fcd" def install system "./configure", "--prefix=#{prefix}" system "make", "install" endend
Homebrew 使 OS X 更完美宋舷。使用 gem
來(lái)安裝 gems、用brew
來(lái)搞定那些依賴包瓢姻。