TL;DR
curl:
REPO=mirrors/oh-my-zsh REMOTE=https://gitee.com/${REPO}.git sh -c "$(curl -fsSL https://gitee.com/mirrors/oh-my-zsh/raw/master/tools/install.sh)"
wget:
REPO=mirrors/oh-my-zsh REMOTE=https://gitee.com/${REPO}.git sh -c "$(wget https://gitee.com/mirrors/oh-my-zsh/raw/master/tools/install.sh -O -)"
这干了啥?
起初搜索改造omz国内镜像源的方法,其他文章中要改install.sh脚本,又要改git远程仓库地址,好麻烦!😑
于是想看看有没有一句话能搞定的方法🤔,把install.sh下载来看看,其中有这几行:
REPO=${REPO:-ohmyzsh/ohmyzsh}
REMOTE=${REMOTE:-https://github.com/${REPO}.git}
BRANCH=${BRANCH:-master}
可以看到这几个变量赋值是这样写的:var=${var:-value}
意思是当var没有值时候就用:-
后面的缺省值value
,否则保留已经存在的值。
那其实没这么麻烦,只需要在执行脚本前设置好REPO
REMOTE
国内镜像源的值就完事。🥳
验证一下:
~ REPO=mirrors/oh-my-zsh REMOTE=https://gitee.com/${REPO}.git sh -c "$(curl -fsSL https://gitee.com/mirrors/oh-my-zsh/raw/master/tools/install.sh)"
~ cd ~/.oh-my-zsh
~ git remote get-url origin
https://gitee.com/mirrors/oh-my-zsh.git
~ git pull
Already up to date.