-
安装 Homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
将以上命令粘贴至终端。脚本会在执行前暂停,并说明将它将做什么。高级安装选项在 这里(需要10.5)。
-
Homebrew 会将软件包安装到独立目录,并将其文件软链接至
/usr/local
。<span class="gp"></span><span class="nb">cd</span> /usr/local <span class="gp"> </span>find Cellar Cellar/wget/1.16.1 Cellar/wget/1.16.1/bin/wget Cellar/wget/1.16.1/share/man/man1/wget.1 <span class="gp">$ </span>ls -l bin bin/wget -> ../Cellar/wget/1.16.1/bin/wget
-
Homebrew 不会将文件安装到它本身目录之外,所以您可将 Homebrew 安装到任意位置。
-
轻松创建你自己的 Homebrew 包。
<span class="gp">$ </span>brew create https://foo.com/bar-1.0.tgz Created /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/bar.rb
-
完全基于 git 和 ruby,所以自由修改的同时你仍可以轻松撤销你的变更或与上游更新合并。
<span class="gp"></span>brew edit wget <span class="c"># 使用EDITOR 编辑!</span>
-
Homebrew 的配方都是简单的 Ruby 脚本:
<span class="k">class</span> <span class="nc">Wget</span> <span class="o"><</span> <span class="no">Formula</span> <span class="n">homepage</span> <span class="s2">"https://www.gnu.org/software/wget/"</span> <span class="n">url</span> <span class="s2">"https://ftp.gnu.org/gnu/wget/wget-1.15.tar.gz"</span> <span class="n">sha256</span> <span class="s2">"52126be8cf1bddd7536886e74c053ad7d0ed2aa89b4b630f76785bac21695fcd"</span> <span class="k">def</span> <span class="nf">install</span> <span class="nb">system</span> <span class="s2">"./configure"</span><span class="p">,</span> <span class="s2">"--prefix=</span><span class="si">#{</span><span class="n">prefix</span><span class="si">}</span><span class="s2">"</span> <span class="nb">system</span> <span class="s2">"make"</span><span class="p">,</span> <span class="s2">"install"</span> <span class="k">end</span> <span class="k">end</span>
-
Homebrew 使 macOS 更完整。使用 gem 来安装 gems、 用 brew 来安装那些依赖包。