|
相当于 Ubuntu/Linux 的 apt-get,用来安装一些零零碎碎的东西很方便,而且更新很快,安装的软件也都是最新版本。
1. 安装
Homebrew 是使用 ruby 写的,采用 github 来存放信息库,很方便吧。
Ruby 已经内置,最好装上 Xcode,因为可能需要一些编译包。然后在终端执行以下命令。
$ ruby -e "$(curl -fsSLk https://gist.github.com/raw/323731/install_homebrew.rb)"
brew 安装的软件存放在 /usr/local/Cellar 中,同时会在 /usr/local/bin, /usr/local/sbin, /usr/local/lib 中创建链接。你可能需要将 /usr/local/sbin 添加到搜索路径中。
$ vim ~/.profile
PATH="$PATH:/usr/local/sbin"
export PATH
2. 使用
(1) 更新库信息
$ brew update
remote: Counting objects: 116, done.
remote: Compressing objects: 100% (95/95), done.
remote: Total 95 (delta 73), reused 0 (delta 0)
Unpacking objects: 100% (95/95), done.
From http://github.com/mxcl/homebrew
* branch master -> FETCH_HEAD
Updated Homebrew from 780c85bd to d7ff3a29.
==> The following formulae are new:
dfu-programmer grass
==> The following formulae were updated:
bash-completion fiwalk git-flow hub mkclean xapian
cherokee flac groovy id3lib mkvalidator
ctags git guile kyoto-cabinet poco
No external commands were updated.
(2) 搜索软件
$ brew search redis
redis redis-tools
$ brew search jpg # 局部搜索
libjpg
$ brew search /^libjp[e]?g/ # 正则表达式搜索
libjpeg libjpg
(3) 查看软件信息
$ brew info redis
redis 2.0.4
http://redis.io/
/usr/local/Cellar/redis/2.0.4 (147 files, 1.2M)
If this is your first install, automatically load on login with:
cp /usr/local/Cellar/redis/2.0.4/io.redis.redis-server.plist ~/Library/LaunchAgents
launchctl load -w ~/Library/LaunchAgents/io.redis.redis-server.plist
If this is an upgrade and you already have the io.redis.redis-server.plist loaded:
launchctl unload -w ~/Library/LaunchAgents/io.redis.redis-server.plist
cp /usr/local/Cellar/redis/2.0.4/io.redis.redis-server.plist ~/Library/LaunchAgents
launchctl load -w ~/Library/LaunchAgents/io.redis.redis-server.plist
To start redis manually:
redis-server /usr/local/etc/redis.conf
To access the server:
redis-cli
http://github.com/mxcl/homebrew/commits/master/Library/Formula/redis.rb
(4) 浏览软件主页
$ brew home redis
(5) 安装软件
$ brew install redis
==> Downloading https://github.com/antirez/redis/tarball/v2.0.4-stable
######################################################################## 100.0%
==> make -C .
==> Caveats
If this is your first install, automatically load on login with:
cp /usr/local/Cellar/redis/2.0.4/io.redis.redis-server.plist ~/Library/LaunchAgents
launchctl load -w ~/Library/LaunchAgents/io.redis.redis-server.plist
If this is an upgrade and you already have the io.redis.redis-server.plist loaded:
launchctl unload -w ~/Library/LaunchAgents/io.redis.redis-server.plist
cp /usr/local/Cellar/redis/2.0.4/io.redis.redis-server.plist ~/Library/LaunchAgents
launchctl load -w ~/Library/LaunchAgents/io.redis.redis-server.plist
To start redis manually:
redis-server /usr/local/etc/redis.conf
To access the server:
redis-cli
==> Summary
/usr/local/Cellar/redis/2.0.4: 147 files, 1.2M, built in 6 seconds
(6) 删除软件
$ brew uninstall redis
Uninstalling /usr/local/Cellar/redis/2.0.4...
(7) 查看已经安装的软件
$ brew list
binutils gettext libevent nginx pstree readline valgrind
erlang glib libiconv pcre python3 redis wget
gdbm libev mongodb pkg-config rabbitmq sqlite
(8) 查看某软件的安装文件
$ brew list redis
/usr/local/Cellar/redis/2.0.4/bin/redis-server
/usr/local/Cellar/redis/2.0.4/bin/redis-cli
/usr/local/Cellar/redis/2.0.4/bin/redis-check-dump
/usr/local/Cellar/redis/2.0.4/bin/redis-check-aof
/usr/local/Cellar/redis/2.0.4/bin/redis-benchmark
/usr/local/Cellar/redis/2.0.4/io.redis.redis-server.plist
/usr/local/Cellar/redis/2.0.4/share/doc/ (138 files)
(9) 查看某软件的 brew 安装脚本
$ brew cat redis
require 'formula'
class Redis |
|
|