安装oh my zsh失败:curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused

记得以前macOS 10.14安装oh my zsh是没问题的,新mac上是macOS 10.15,安装oh my zsh会报错curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused
百度了很多办法都不能解决。

后来看到了这篇文章下载加速Clone、AWS、Git镜像试了试果然成功了(不用翻墙)

## GitHub Start

192.30.253.112 github.com
192.30.253.113 github.com
151.101.184.133 assets-cdn.github.com
151.101.185.194 github.global.ssl.fastly.net 


192.30.253.112 github.com
192.30.253.113 github.com
192.30.253.118 gist.github.com
151.101.185.194 github.global.ssl.fastly.net
151.101.129.194 github.global.ssl.fastly.net
151.101.65.194 github.global.ssl.fastly.net
151.101.1.194 github.global.ssl.fastly.net
151.101.193.194 github.global.ssl.fastly.net
151.101.77.194 github.global.ssl.fastly.net
151.101.229.194 github.global.ssl.fastly.net
151.101.113.194 github.global.ssl.fastly.net
151.101.196.133 assets-cdn.github.com
151.101.24.133 assets-cdn.github.com
185.199.111.153 assets-cdn.github.com
185.199.110.153 assets-cdn.github.com
185.199.108.153 assets-cdn.github.com
185.199.109.153 assets-cdn.github.com
151.101.112.133 assets-cdn.github.com

151.101.112.133 avatars0.githubusercontent.com
151.101.112.133 avatars1.githubusercontent.com
151.101.184.133 avatars2.githubusercontent.com
151.101.12.133 avatars3.githubusercontent.com
151.101.12.133 avatars4.githubusercontent.com
151.101.184.133 avatars5.githubusercontent.com
151.101.184.133 avatars6.githubusercontent.com
151.101.184.133 avatars7.githubusercontent.com
151.101.12.133 avatars8.githubusercontent.com

151.101.184.133 raw.githubusercontent.com
151.101.112.133 gist.githubusercontent.com
151.101.184.133 cloud.githubusercontent.com
151.101.112.133 camo.githubusercontent.com
52.216.227.168 github-cloud.s3.amazonaws.com

192.30.253.112 github.com
185.199.108.153 assets-cdn.github.com
151.101.185.194 github.global.ssl.fastly.net
140.82.113.10 codeload.github.com

## GitHub End

闲麻烦不想配置hosts,也可以直接执行下面这些命令,把这些命令拷贝到sh文件然后执行即可。这些命令就是https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh里面的命令,拷贝出来方便以后使用

#!/bin/sh

set -e

ZSH=${ZSH:-~/.oh-my-zsh}
REPO=${REPO:-ohmyzsh/ohmyzsh}
REMOTE=${REMOTE:-https://github.com/${REPO}.git}
BRANCH=${BRANCH:-master}

CHSH=${CHSH:-yes}
RUNZSH=${RUNZSH:-yes}
KEEP_ZSHRC=${KEEP_ZSHRC:-no}


command_exists() {
    command -v "$@" >/dev/null 2>&1
}

error() {
    echo ${RED}"Error: $@"${RESET} >&2
}

setup_color() {
    
    if [ -t 1 ]; then
        RED=$(printf '\033[31m')
        GREEN=$(printf '\033[32m')
        YELLOW=$(printf '\033[33m')
        BLUE=$(printf '\033[34m')
        BOLD=$(printf '\033[1m')
        RESET=$(printf '\033[m')
    else
        RED=""
        GREEN=""
        YELLOW=""
        BLUE=""
        BOLD=""
        RESET=""
    fi
}

setup_ohmyzsh() {
    
    umask g-w,o-w

    echo "${BLUE}Cloning Oh My Zsh...${RESET}"

    command_exists git || {
        error "git is not installed"
        exit 1
    }

    if [ "$OSTYPE" = cygwin ] && git --version | grep -q msysgit; then
        error "Windows/MSYS Git is not supported on Cygwin"
        error "Make sure the Cygwin git package is installed and is first on the \$PATH"
        exit 1
    fi

    git clone -c core.eol=lf -c core.autocrlf=false \
        -c fsck.zeroPaddedFilemode=ignore \
        -c fetch.fsck.zeroPaddedFilemode=ignore \
        -c receive.fsck.zeroPaddedFilemode=ignore \
        --depth=1 --branch "$BRANCH" "$REMOTE" "$ZSH" || {
        error "git clone of oh-my-zsh repo failed"
        exit 1
    }

    echo
}

setup_zshrc() {
    
    echo "${BLUE}Looking for an existing zsh config...${RESET}"

    OLD_ZSHRC=~/.zshrc.pre-oh-my-zsh
    if [ -f ~/.zshrc ] || [ -h ~/.zshrc ]; then
        
        if [ $KEEP_ZSHRC = yes ]; then
            echo "${YELLOW}Found ~/.zshrc.${RESET} ${GREEN}Keeping...${RESET}"
            return
        fi
        if [ -e "$OLD_ZSHRC" ]; then
            OLD_OLD_ZSHRC="${OLD_ZSHRC}-$(date +%Y-%m-%d_%H-%M-%S)"
            if [ -e "$OLD_OLD_ZSHRC" ]; then
                error "$OLD_OLD_ZSHRC exists. Can't back up ${OLD_ZSHRC}"
                error "re-run the installer again in a couple of seconds"
                exit 1
            fi
            mv "$OLD_ZSHRC" "${OLD_OLD_ZSHRC}"

            echo "${YELLOW}Found old ~/.zshrc.pre-oh-my-zsh." \
                "${GREEN}Backing up to ${OLD_OLD_ZSHRC}${RESET}"
        fi
        echo "${YELLOW}Found ~/.zshrc.${RESET} ${GREEN}Backing up to ${OLD_ZSHRC}${RESET}"
        mv ~/.zshrc "$OLD_ZSHRC"
    fi

    echo "${GREEN}Using the Oh My Zsh template file and adding it to ~/.zshrc.${RESET}"

    sed "/^export ZSH=/ c\\
export ZSH=\"$ZSH\"
" "$ZSH/templates/zshrc.zsh-template" > ~/.zshrc-omztemp
    mv -f ~/.zshrc-omztemp ~/.zshrc

    echo
}

setup_shell() {

    if [ $CHSH = no ]; then
        return
    fi

    if [ "$(basename "$SHELL")" = "zsh" ]; then
        return
    fi

    if ! command_exists chsh; then
        cat <<-EOF
            I cannot change your shell automatically because this system does not have chsh.
            ${BLUE}Please manually change your default shell to zsh${RESET}
        EOF
        return
    fi

    echo "${BLUE}Time to change your default shell to zsh:${RESET}"

    printf "${YELLOW}Do you want to change your default shell to zsh? [Y/n]${RESET} "
    read opt
    case $opt in
        y*|Y*|"") echo "Changing the shell..." ;;
        n*|N*) echo "Shell change skipped."; return ;;
        *) echo "Invalid choice. Shell change skipped."; return ;;
    esac

    case "$PREFIX" in
        *com.termux*) termux=true; zsh=zsh ;;
        *) termux=false ;;
    esac

    if [ "$termux" != true ]; then
        
        if [ -f /etc/shells ]; then
            shells_file=/etc/shells
        elif [ -f /usr/share/defaults/etc/shells ]; then 
            shells_file=/usr/share/defaults/etc/shells
        else
            error "could not find /etc/shells file. Change your default shell manually."
            return
        fi

        if ! zsh=$(which zsh) || ! grep -qx "$zsh" "$shells_file"; then
            if ! zsh=$(grep '^/.*/zsh$' "$shells_file" | tail -1) || [ ! -f "$zsh" ]; then
                error "no zsh binary found or not present in '$shells_file'"
                error "change your default shell manually."
                return
            fi
        fi
    fi

    if [ -n "$SHELL" ]; then
        echo $SHELL > ~/.shell.pre-oh-my-zsh
    else
        grep "^$USER:" /etc/passwd | awk -F: '{print $7}' > ~/.shell.pre-oh-my-zsh
    fi

    if ! chsh -s "$zsh"; then
        error "chsh command unsuccessful. Change your default shell manually."
    else
        export SHELL="$zsh"
        echo "${GREEN}Shell successfully changed to '$zsh'.${RESET}"
    fi

    echo
}

main() {

    if [ ! -t 0 ]; then
        RUNZSH=no
        CHSH=no
    fi

    while [ $# -gt 0 ]; do
        case $1 in
            --unattended) RUNZSH=no; CHSH=no ;;
            --skip-chsh) CHSH=no ;;
            --keep-zshrc) KEEP_ZSHRC=yes ;;
        esac
        shift
    done

    setup_color

    if ! command_exists zsh; then
        echo "${YELLOW}Zsh is not installed.${RESET} Please install zsh first."
        exit 1
    fi

    if [ -d "$ZSH" ]; then
        cat <<-EOF
            ${YELLOW}You already have Oh My Zsh installed.${RESET}
            You will need to remove '$ZSH' if you want to reinstall.
        EOF
        exit 1
    fi

    setup_ohmyzsh
    setup_zshrc
    setup_shell

    printf "$GREEN"
    cat <<-'EOF'
                 __                                     __
          ____  / /_     ____ ___  __  __   ____  _____/ /_
         / __ \/ __ \   / __ `__ \/ / / /  /_  / / ___/ __ \
        / /_/ / / / /  / / / / / / /_/ /    / /_(__  ) / / /
        \____/_/ /_/  /_/ /_/ /_/\__, /    /___/____/_/ /_/
                                /____/                       ....is now installed!


        Please look over the ~/.zshrc file to select plugins, themes, and options.

    EOF
    printf "$RESET"

    if [ $RUNZSH = no ]; then
        echo "${YELLOW}Run zsh to try it out.${RESET}"
        exit
    fi

    exec zsh -l
}

main "$@"

查看当前shell命令echo $SHELL
查看已安装的shell命令cat /etc/shells
切换zsh命令chsh -s /bin/zsh
切换bash命令chsh -s /bin/bash

git常用命令总结

oh my zsh 缩写 原git命令 描述
gst git status 查看当前仓库状态
gaa git add --all 将所有改动添加到暂存区
gcmsg git commit -m 将暂存区提交
gb git branch 查看本地分支
gfo git fetch origin 更新远程分支列表
gba git branch -a 查看所有分支
gbd git branch -d 删除某分支
gbD git branch -D 强制删除某分支
gcb git checkout -b 创建分支并切换
gco git checkout 切换分支
gl git pull 拉代码
gp git push 推代码
gm git merge 合并分支
ggsup git branch --set-upstream-to=origin/$(git_current_branch) 绑定远程同名分支
gpsup git push --set-upstream origin $(git_current_branch) 在远程创建同名分支并关联后将代码推上去
gsta git stash push 将当前改动加入缓存
gstc git stash clear 清空所有缓存
gstl git stash list 查看缓存列表
gstp git stash pop 将最新一条缓存读取出来并删除缓存
grhh git reset --hard 回退到某个commit版本
groh git reset origin/$(git_current_branch) --hard 将远程仓库同名分支回退到某个commit版本
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 204,445评论 6 478
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 85,889评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 151,047评论 0 337
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,760评论 1 276
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,745评论 5 367
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,638评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 38,011评论 3 398
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,669评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,923评论 1 299
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,655评论 2 321
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,740评论 1 330
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,406评论 4 320
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,995评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,961评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,197评论 1 260
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 45,023评论 2 350
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,483评论 2 342