MacBook pro OS catalina 安装oh-my-zsh,homebrew, Command_Line_Tools_for_Xcode

新入手一代macbook pro 16 寸,然后发现terminal 颜色太差,想调整一下颜色,准备下载oh-my-zsh,安装的时候发现巨多坑。

我的os未升级,版本为 macOS Catalina Version 10.14.0

首先你采用美化并增强Mac终端介绍的方法,在终端中运行:

@macbook ~ $ git clone https://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
xcode-select: note: no developer tools were found at '/Applications/Xcode.app', requesting install. Choose an option in the dialog to download the command line developer tools.

@macbook ~ $ which brew
brew not found

报错没有安装开发工具

安装home brew,git,开发工具等

用ruby安装

按照stack overflow上的介绍,运行以下命令:

@macbook ~ $ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused

报错无法链接,原因类似404,解决办法自己找

然后通过高人帮忙打开在chrome中把https://raw.githubusercontent.com/Homebrew/install/master/install粘贴打开网站发现换了地址和安装方法:

在这里插入图片描述
中间还测试了安装brew命令遇到坑sudo vim /etc/hosts, 在最后一行加上“199.232.28.133 raw.githubusercontent.com” 保存后,还是不行。

@macbook ~ $ sudo vim /etc/hosts
Password:
@macbook ~ $ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"        
curl: (35) LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to raw.githubusercontent.com:443 

依然不行

用bash安装

按照上面网页的介绍,采用bash命令安装

@macbook ~ $ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
curl: (35) LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to raw.githubusercontent.com:443 

依然报错,链接问题。

没办法,绕过404在浏览器打开“https://raw.githubusercontent.com/Homebrew/install/master/install.sh”,将shell代码另存为“install.rb”
运行:

macbook Downloads $ ruby install.rb 
Traceback (most recent call last):
ruby: no Ruby script found in input (LoadError)

显示不是ruby代码,改用bash

macbook Downloads $ bash brew_install.rb 
Password:
==> 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/bin
/usr/local/etc
/usr/local/include
/usr/local/lib
/usr/local/sbin
/usr/local/share
/usr/local/var
/usr/local/opt
/usr/local/share/zsh
/usr/local/share/zsh/site-functions
/usr/local/var/homebrew
/usr/local/var/homebrew/linked
/usr/local/Cellar
/usr/local/Caskroom
/usr/local/Homebrew
/usr/local/Frameworks
==> The Xcode Command Line Tools will be installed.

Press RETURN to continue or any other key to abort
==> /usr/bin/sudo /bin/mkdir -p /usr/local/bin /usr/local/etc /usr/local/include /usr/local/lib /usr/local/sbin /usr/local/share /usr/local/var /usr/local/opt /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var/homebrew /usr/local/var/homebrew/linked /usr/local/Cellar /usr/local/Caskroom /usr/local/Homebrew /usr/local/Frameworks
==> /usr/bin/sudo /bin/chmod g+rwx /usr/local/bin /usr/local/etc /usr/local/include /usr/local/lib /usr/local/sbin /usr/local/share /usr/local/var /usr/local/opt /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var/homebrew /usr/local/var/homebrew/linked /usr/local/Cellar /usr/local/Caskroom /usr/local/Homebrew /usr/local/Frameworks
==> /usr/bin/sudo /usr/sbin/chown zouxiaohui /usr/local/bin /usr/local/etc /usr/local/include /usr/local/lib /usr/local/sbin /usr/local/share /usr/local/var /usr/local/opt /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var/homebrew /usr/local/var/homebrew/linked /usr/local/Cellar /usr/local/Caskroom /usr/local/Homebrew /usr/local/Frameworks
==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/bin /usr/local/etc /usr/local/include /usr/local/lib /usr/local/sbin /usr/local/share /usr/local/var /usr/local/opt /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var/homebrew /usr/local/var/homebrew/linked /usr/local/Cellar /usr/local/Caskroom /usr/local/Homebrew /usr/local/Frameworks
==> /usr/bin/sudo /bin/mkdir -p /Users/zouxiaohui/Library/Caches/Homebrew
==> /usr/bin/sudo /bin/chmod g+rwx /Users/zouxiaohui/Library/Caches/Homebrew
==> /usr/bin/sudo /usr/sbin/chown zouxiaohui /Users/zouxiaohui/Library/Caches/Homebrew
==> Searching online for the Command Line Tools
==> /usr/bin/sudo /usr/bin/touch /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress
==> Installing the Command Line Tools (expect a GUI popup):
==> /usr/bin/sudo /usr/bin/xcode-select --install
xcode-select: note: install requested for command line developer tools
Press any key when the installation has completed.
==> /usr/bin/sudo /usr/bin/xcode-select --switch /Library/Developer/CommandLineTools
xcode-select: error: invalid developer directory '/Library/Developer/CommandLineTools'
Failed during: /usr/bin/sudo /usr/bin/xcode-select --switch /Library/Developer/CommandLineTools

@macbook Downloads $ which brew
brew not found

bash 可以运行这个代码,但在安装CommandLineTools 时出现“Can’t install the software because it is not currently available from the Software Update server.“错误

升级系统解决问题

由于无法下载,直接去苹果官网下载了,Command_Line_Tools_for_Xcode_12.dmg,安装过程中出现了该工具🈯️适合catalina 14.20 以上的系统,因此,点击左上角苹果图标,升级os到最新的10.15.17。

因此bash命令失败的原因可能是系统版本太低,升级后用bash脚本安装:

@macbook Downloads % bash brew_install.rb 
Password:
==> This script will install:
/usr/local/bin/brew
....
==> Installing Command Line Tools for Xcode-12.0
==> /usr/bin/sudo /usr/sbin/softwareupdate -i Command\ Line\ Tools\ for\ Xcode-12.0
Software Update Tool


Downloading Command Line Tools for Xcode
Downloaded Command Line Tools for Xcode
Installing Command Line Tools for Xcode
Done with Command Line Tools for Xcode
Done.
==> /usr/bin/sudo /bin/rm -f /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress
==> /usr/bin/sudo /usr/bin/xcode-select --switch /Library/Developer/CommandLineTools
==> Downloading and installing Homebrew...
remote: Enumerating objects: 44, done.
remote: Counting objects: 100% (44/44), done.
remote: Compressing objects: 100% (44/44), done.
remote: Total 155382 (delta 0), reused 43 (delta 0), pack-reused 155338
Receiving objects: 100% (155382/155382), 39.65 MiB | 586.00 KiB/s, done.
Resolving deltas: 100% (114840/114840), done.
From https://github.com/Homebrew/brew
 * [new branch]      master     -> origin/master
 * [new tag]             0.1        -> 0.1
 * [new tag]             0.2        -> 0.2

@macbook Downloads % brew help
Example usage:
  brew search [TEXT|/REGEX/]
  brew info [FORMULA...]
  brew install FORMULA...
  brew update

home brew 安装成功,只需要升级os 到最新的版本,然后运行bash 命令就行。

安装oh-my-zsh

按照duan847的安装方法如下:


# 下载oh-my-zsh
git clone https://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh

# 创建一个新的配置文件
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc

# 授权,如果不授权每次会有警告
chmod 755 /usr/local/share/zsh
chmod 755 /usr/local/share/zsh/site-functions
复制代码退出终端Command + Q,重新启动终端:

效果如下:
在这里插入图片描述

修改命令提示符

由于一直喜欢用$符号作为命令提示符,因此在 .zshrc文件最好一行加上
export PS1="%n@%m %1~ $ ,然后source .zshrc 即可。

教训

一定要先将系统升级到最新版本

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值