集美们,强烈推荐好吗?
- 跨平台的软件包管理工具,去哪个系统都不会迷路。
用了它你就是和苹果用户一样的 👩🏻💻Fashion👨🏻💻 的弄潮儿 - 带着你的 ThinkPad 去 斯达巴克斯,一样有面儿。再也不会有服务员对你说:“麻烦那边坐地铁🚇,6个站,大卡司。”
还不心动吗,还不安装吗。
- 一个是去找github上的源码,下下来以后,用里面的intall.sh文件安装
(我的oh-my-zsh就是这么装的) - 这个Homebrew我找到了官方网站,按照上面的整了一通就好了
CentOS可以去看官网的链接,过程差不多
首先安装依赖
应该需要这几个,其他没写到的系统,可以自己装一下
curl file git
Debian or Ubuntu
sudo apt-get install build-essential curl file git
Fedora, CentOS, or Red Hat
sudo yum groupinstall 'Development Tools'
sudo yum install curl file git
sudo yum install libxcrypt-compat # needed by Fedora 30 and up
之后安装软件
应该不区分Linux系统
git clone https://github.com/Homebrew/brew ~/.linuxbrew/Homebrew
mkdir ~/.linuxbrew/bin
ln -s ~/.linuxbrew/Homebrew/bin/brew ~/.linuxbrew/bin
eval $(~/.linuxbrew/bin/brew shellenv)
到这里应该就结束了。
顺便说一下换源
#清华和中科大选一个就好啦
cd "$(brew --repo)"
# 中国科大:
git remote set-url origin https://mirrors.ustc.edu.cn/brew.git
# 清华大学:
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
# 替换homebrew-core.git:
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
# 中国科大:
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
# 清华大学:
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
# 替换homebrew-bottles:
# 中国科大:
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile
# 清华大学:
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile
# 应用生效:
brew update
顺便提一下怎么重置源,我就是不小心重置了 ( q w q )
# 重置brew.git:
cd "$(brew --repo)"
git remote set-url origin https://github.com/Homebrew/brew.git
# 重置homebrew-core.git:
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://github.com/Homebrew/homebrew-core.git
换源相关来自这里
附上常用命令
安装软件
brew的安装目录在 /usr/local/Cellar,我们以安装nodejs为例子,只需要执行:
brew install nodejs
就安装完了,就这么简单
更新软件
brew upgrade nodejs
卸载软件
brew remove nodejs
全是一条命令。
在介绍几条其他命令:
brew list # 列出当前安装的软件
brew search nodejs # 查询与 nodejs 相关的可用软件
brew info nodejs # 查询 nodejs 的安装信息
如果需要安装指定版本的软件,执行 brew search 查看有没有需要的版本
在 @ 后面指定版本号,例如 brew install thrift@0.9
brew services
brew services 是一个非常强大的工具,可以管理软件,进行停止、重启等
brew install elasticsearch # 安装 elasticsearch
brew services start elasticsearch # 启动 elasticsearch
brew services stop elasticsearch # 停止 elasticsearch
brew services restart elasticsearch # 重启 elasticsearch
brew services list # 列出当前的状态