---
title: "mac 获取 Homebrew"
author: "ronin47"
date: "2015-12-12T11:04:24Z"
tags: []
categories: ["操作系统"]
slug: "mac-homebrew"
draft: false
lastmod: "2015-12-12T11:04:55Z"
id: 2263597
url: "https://hugoren.iteye.com/blog/2263597"
---

- ```
  ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  ```
  
  打开终端窗口, 粘贴以上脚本。
  
  脚本会解释它的作用，然后在您的确认下执行安装。高级安装选项请看 [这里](https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/Installation.md#installation)（需要10.5）。
- ## What Does Homebrew Do?
  
  又提示缺少套件啦？别担心，Homebrew [随时守候](https://github.com/Homebrew/homebrew/tree/master/Library/Formula "Homebrew 软件包列表")。
  
   
  
  reference:http://brew.sh/index\_zh-cn.html
  
  ```bash
  $ brew install wget
  ```
- Homebrew 会将套件安装到独立目录，并将文件软链接至`/usr/local` 。
  
  ```bash
  $ cd /usr/local
  $ find Cellar
  Cellar/wget/1.16.1
  Cellar/wget/1.16.1/bin/wget
  Cellar/wget/1.16.1/share/man/man1/wget.1
  
  $ ls -l bin
  bin/wget -> ../Cellar/wget/1.16.1/bin/wget
  ```
- Homebrew 的所有文件均会被安装到预定义目录下，所以您无需担心 Homebrew 的安装位置。
- 轻松创建您的 Homebrew 程式。
  
  ```bash
  $ brew create https://foo.com/bar-1.0.tgz
  Created /usr/local/Library/Formula/bar.rb
  ```
- 以 git、 ruby 为其筋骨，所以借助您的相关知识，自由修改，并且可以简单撤回您的调改或者合并上游更新。
  
  ```bash
  $ brew edit wget # 使用 $EDITOR 编辑!
  ```
- Homebrew 的程式都是简单的 Ruby 脚本：
  
  ```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"
    end
  end
  ```
- Homebrew 使 OS X 更完美。使用 `gem` 来安装 gems、用`brew` 来搞定那些依赖包。
- ## 更多文档
  
  [https://git.io/brew-docs](https://git.io/brew-docs)