Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Homebrew:macOS软件包管理工具 #59

Open
Qingquan-Li opened this issue Sep 25, 2017 · 1 comment
Open

Homebrew:macOS软件包管理工具 #59

Qingquan-Li opened this issue Sep 25, 2017 · 1 comment
Labels

Comments

@Qingquan-Li
Copy link
Owner

Qingquan-Li commented Sep 25, 2017

一、安装 Homebrew

  • Homebrew 是 macOS 上的软件包管理工具,能在 Mac 中方便的安装软件或者卸载软件,相当于 apt-get 之于 ubuntu , rpm 之于 centos ;
  • Homebrew 依 赖 于 Apple 包 Xcode, 因 此 请 打 开 一 个 终 端 窗 口 并 执 行 如 下 命 令:
    $ xcode-select --install ,在 不 断 出 现 的 确 认 对 话 框 中 都 单 击 OK 按 钮。
  • Homebrew 可以在 Mac 上安装一些 macOS 没有的 UNIX 工具,Homebrew 将这些工具统统安装到了 /usr/local/Cellar 目录中,并在 /usr/local/bin 中创建符号链接( Homebrew 安装成功后,会自动创建目录 /usr/local/Cellar 来存放 Homebrew 安装的程序)。
  • 安装命令:
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

然后 enter 回车,输入密码后基本是等(有梯子 - 4M 网速下,5分钟左右)

注:这 个 命 令 可 在 Homebrew 网 站( http://brew.sh )的 首 页 找 到。 在 curl -fsSL 和 URL 之 间, 务 必 包 含 一 个 空 格。 注 意   这 个 命 令 中 的-e 让 Ruby( Homebrew 就 是 使 用 这 种 编 程 语 言 编 写 的) 执 行 下 载 的 代 码。 除 非 来 源 是 你 信 任 的, 否 则 不 要 运 行 这 样 的 命 令。

为 确 认 正 确 地 安 装 了 Homebrew, 请 执 行 如 下 命 令: $ brew doctor


二、Homebrew 的使用

  • 安装软件(包):brew install 软件名 ,例:brew install wget
  • 卸载软件:brew uninstall 软件名 ,例:brew uninstall wget
  • 搜索软件:brew search 软件名 ,例:brew search wget

  • 显示已安装软件:brew list (显示使用 brew install 命令安装的软件)

  • 查看哪些已安装的程序需要更新:brew outdated
  • 更新所有软件:brew upgrade
  • 更新具体软件:brew upgrade 软件名 ,例:brew upgrade git

  • 清理所有软件的旧版本:brew cleanup
  • 清理具体软件的旧版本:brew cleanup 软件名
  • 查看软件可清理的旧版本,不执行实际操作:brew cleanup -n

  • 锁定不想更新的软件:brew pin 软件名字
  • 取消锁定不想更新的软件:brew unpin 软件名字

  • 显示安装了的软件数量、文件数量,和总占用空间:brew info
  • 查看具体软件的信息:brew info/home 软件名 ( brew home 指令是用浏览器打开官方网页查看软件信息) ,例:brew info gitbrew home git

  • 查看已安装的包依赖,以树形显示:brew deps --installed --tree

三、关于 Homebrew 更新的问题

Homebrew 每次安装新东西, 它都要先去 update 一下,怎么才能不 update, 直接安装我们想要的包呢?

  • control+c 按一下终止 update ,然后继续马上安装包
  • control+c 再按一下,终止所有操作

关闭 Homebrew 自动更新

$ export HOMEBREW_NO_AUTO_UPDATE=true

如果想要重启后设置依然生效,可以把上面这行加入到当前正在使用的 shell 的配置文件中。例如,正在使用的是 zsh ,那么执行以下语句:

$ vi ~/.zshrc

手动更新 Homebrew

$ brew update
@Qingquan-Li Qingquan-Li changed the title HomebrewmacOS软件包管理工具 Homebrew:macOS软件包管理工具 Sep 25, 2017
This was referenced Oct 4, 2017
@Qingquan-Li
Copy link
Owner Author

安装 Python (brew):

  1. brew install python ,若报错,在前面加上 sudo
  2. brew install python ,默认安装最新版 Python

安装 pip ( wget):

  1. 获取 pip 的安装脚本 : wget https://bootstrap.pypa.io/get-pip.py
  2. 安装 pip : sudo python get-pip.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant