Brew
brew 又叫 Homebrew,是 Mac OSX上的软件包管理工具。类似 ubuntu 中的 apt-get
。
- Install
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
如下
houbinbindeMacBook-Pro:tools houbinbin$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
==> This script will install:
/usr/local/bin/brew
/usr/local/share/doc/homebrew
/usr/local/share/man/man1/brew.1
/usr/local/share/zsh/site-functions/_brew
/usr/local/etc/bash_completion.d/brew
/usr/local/Homebrew
==> The following existing directories will be made group writable:
/usr/local/bin
/usr/local/etc
/usr/local/lib
/usr/local/share
/usr/local/share/doc
/usr/local/share/man
/usr/local/share/man/man1
/usr/local/share/man/man3
/usr/local/share/man/man5
/usr/local/share/man/man7
==> The following existing directories will have their owner set to houbinbin:
/usr/local/bin
/usr/local/lib
/usr/local/share
/usr/local/share/doc
/usr/local/share/man
/usr/local/share/man/man1
/usr/local/share/man/man3
/usr/local/share/man/man5
/usr/local/share/man/man7
==> The following existing directories will have their group set to admin:
/usr/local/bin
/usr/local/lib
/usr/local/share
/usr/local/share/doc
/usr/local/share/man
/usr/local/share/man/man1
/usr/local/share/man/man3
/usr/local/share/man/man5
/usr/local/share/man/man7
==> The following new directories will be created:
/usr/local/Cellar
/usr/local/Homebrew
/usr/local/Frameworks
/usr/local/etc
/usr/local/opt
/usr/local/sbin
/usr/local/share/zsh
/usr/local/share/zsh/site-functions
/usr/local/var
Press RETURN to continue or any other key to abort
==> /usr/bin/sudo /bin/chmod u+rwx /usr/local/bin /usr/local/etc /usr/local/lib /usr/local/share /usr/local/share/doc /usr/local/share/man /usr/local/share/man/man1 /usr/local/share/man/man3 /usr/local/share/man/man5 /usr/local/share/man/man7
Password:
==> /usr/bin/sudo /bin/chmod g+rwx /usr/local/bin /usr/local/etc /usr/local/lib /usr/local/share /usr/local/share/doc /usr/local/share/man /usr/local/share/man/man1 /usr/local/share/man/man3 /usr/local/share/man/man5 /usr/local/share/man/man7
==> /usr/bin/sudo /usr/sbin/chown houbinbin /usr/local/bin /usr/local/lib /usr/local/share /usr/local/share/doc /usr/local/share/man /usr/local/share/man/man1 /usr/local/share/man/man3 /usr/local/share/man/man5 /usr/local/share/man/man7
==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/bin /usr/local/lib /usr/local/share /usr/local/share/doc /usr/local/share/man /usr/local/share/man/man1 /usr/local/share/man/man3 /usr/local/share/man/man5 /usr/local/share/man/man7
==> /usr/bin/sudo /bin/mkdir -p /usr/local/Cellar /usr/local/Homebrew /usr/local/Frameworks /usr/local/etc /usr/local/opt /usr/local/sbin /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var
mkdir: /usr/local/etc: Not a directory
Failed during: /usr/bin/sudo /bin/mkdir -p /usr/local/Cellar /usr/local/Homebrew /usr/local/Frameworks /usr/local/etc /usr/local/opt /usr/local/sbin /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var
1、 遇到这个报错
mkdir: /usr/local/etc: Not a directory
不知道原来为何有一个 etc
文件。估计是 redis 相关的。复制成了其他名称然后删除了。重新跑。
2、 第二个问题
/usr/local/Homebrew/.git: Permission denied
Failed during: git init -q
我的解决方式, 删除2个文件夹
sudo rm -rf /usr/local/Cellar
sudo rm -rf /usr/local/Homebrew
重新运行
houbinbindeMacBook-Pro:local houbinbin$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
==> This script will install:
/usr/local/bin/brew
/usr/local/share/doc/homebrew
/usr/local/share/man/man1/brew.1
/usr/local/share/zsh/site-functions/_brew
/usr/local/etc/bash_completion.d/brew
/usr/local/Homebrew
==> The following new directories will be created:
/usr/local/Cellar
/usr/local/Homebrew
Press RETURN to continue or any other key to abort
==> /usr/bin/sudo /bin/mkdir -p /usr/local/Cellar /usr/local/Homebrew
==> /usr/bin/sudo /bin/chmod g+rwx /usr/local/Cellar /usr/local/Homebrew
==> /usr/bin/sudo /bin/chmod 755 /usr/local/share/zsh /usr/local/share/zsh/site-functions
==> /usr/bin/sudo /usr/sbin/chown houbinbin /usr/local/Cellar /usr/local/Homebrew
==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/Cellar /usr/local/Homebrew
==> Downloading and installing Homebrew...
remote: Counting objects: 5292, done.
remote: Compressing objects: 100% (3328/3328), done.
remote: Total 5292 (delta 2877), reused 3505 (delta 1791), pack-reused 0
Receiving objects: 100% (5292/5292), 2.78 MiB | 82.00 KiB/s, done.
Resolving deltas: 100% (2877/2877), done.
From https://github.com/Homebrew/brew
* [new branch] master -> origin/master
* ...
HEAD is now at fa34aa2 Merge pull request #2232 from reitermarkus/spec-mktmpdir
==> Tapping homebrew/core
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'...
remote: Counting objects: 4165, done.
remote: Compressing objects: 100% (4018/4018), done.
remote: Total 4165 (delta 32), reused 434 (delta 10), pack-reused 0
Receiving objects: 100% (4165/4165), 3.31 MiB | 62.00 KiB/s, done.
Resolving deltas: 100% (32/32), done.
Checking connectivity... done.
Tapped 4016 formulae (4,196 files, 10.4M)
==> Cleaning up /Library/Caches/Homebrew...
==> Migrating /Library/Caches/Homebrew to /Users/houbinbin/Library/Caches/Homebrew...
==> Deleting /Library/Caches/Homebrew...
Already up-to-date.
Error: Failed to link all completions, docs and manpages:
Permission denied - (../../../Homebrew/completions/zsh/_brew, /usr/local/share/zsh/site-functions/_brew)
Failed during: /usr/local/bin/brew update --force
没有错,又报错了。。。心累。因为此时的 brew
命令已经是有效的了,我想直接卸载再重装。或者先用着再说。
- Un-install
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
删除后重新安装。OKay
- Usage
houbinbindeMacBook-Pro:local houbinbin$ brew install tree
Updating Homebrew...
==> Downloading https://homebrew.bintray.com/bottles/tree-1.7.0.el_capitan.bottle.1.tar.gz
######################################################################## 100.0%
curl: (33) HTTP server doesn't seem to support byte ranges. Cannot resume.
==> Trying a full download
######################################################################## 100.0%
==> Pouring tree-1.7.0.el_capitan.bottle.1.tar.gz
🍺 /usr/local/Cellar/tree/1.7.0: 7 files, 113.3K
使用 tree --help
可查看 此命令使用方式。
端口占用
命令 lsof -i tcp:port
(port替换成端口号,比如6379)可以查看该端口被什么程序占用,并显示PID,方便KILL
目录直达
CMD+SHIF+G
or
命令行打开指定路径,然后 open .