安装HomeBrew
第一步是访问HomeBrew网站,并复制红色框
第二步是将复制的代码粘贴到终端执行
如果执行的时候报如下错误:
curl: (6) Could not resolve host: raw.githubusercontent.com,表示raw.githubusercontent.com的ip不对。
解决方案:
1.sudo vi /etc/hosts
2.199.232.68.133 raw.githubusercontent.com添加至最后一行
3.保存退出,重新执行
homebrew添加清华源:
重置brew.git
cd "$(brew --repo)"
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.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
重置homebrew-bottles
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.bash_profile
最后source文件
source ~/.bash_profile
安装Htop:
brew install htop
安装htop后,运行时报如下错误:
htop: command not found
然后再安装htop会提示:
Warning: htop 2.2.0_1 is already installed, it's just not linked
然后输入:
brew link htop
会返回如下信息:
Linking /usr/local/Cellar/htop/2.2.0_1...
Error: Could not symlink bin/htop
Target /usr/local/bin/htop
already exists. You may want to remove it:
rm '/usr/local/bin/htop'
To force the link and overwrite all conflicting files:
brew link --overwrite htop
To list all files that would be deleted:
brew link --overwrite --dry-run htop
就按照这个提示依次输入命令:
rm '/usr/local/bin/htop'
brew link --overwrite htop
brew link --overwrite --dry-run htop
如过中间有提示不能写入之类的错误,使用如下命令
sudo chown -R `whoami`:admin /usr/local/..(根据自己的路径)