开发环境:国内用清华源安装homebrew和oh my zsh

3,481 阅读1分钟

本篇文章简单的记录了在mac系统如何利用清华大学源进行 homebrew 和 oh my zsh 的安装,需要确保系统中安装了bash、git 和 curl,对于 macOS 用户需要安装 Command Line Tools (CLT) for Xcode(安装命令:xcode-select --install,如果已经安装请忽略)。

1. 安装homebrew

1.1 第一步


export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git"
export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git"
export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles"

1.2 第二步


git clone --depth=1 https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/install.git brew-install
/bin/bash brew-install/install.sh
rm -rf brew-install

安装完成后,针对M1新款mac系统(命令行运行 uname -m 应输出 arm64),执行命令

test -r ~/.bash_profile && echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.bash_profile

1.3 第三步

替换下载源

export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git"
for tap in core cask{,-fonts,-drivers,-versions} command-not-found; do
    brew tap --custom-remote --force-auto-update "homebrew/${tap}" "https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-${tap}.git"
done
brew update

过程中可能会出现的问题: zsh command not found,在家目录下执行命令

ls -al
vim .zshrc  
source .bash_profile # 在.zshrc文件尾部添加

然后再执行第三步中的命令

2. 安装oh my zsh

git clone https://mirrors.tuna.tsinghua.edu.cn/git/ohmyzsh.git
cd ohmyzsh/tools
REMOTE=https://mirrors.tuna.tsinghua.edu.cn/git/ohmyzsh.git sh install.sh
rm -rf omhmzsh

3. 其他

zsh 常用插件

zsh-syntax-highlighting :提供了语法高亮显示。

zsh-autosuggestions :它会根据历史记录和完成情况建议您键入的命令,而且快速/不干扰自动提示。

zsh-completions :命令自动补全。

  • 国内安装源 这些安装源是在 gitee 上找到的,如果不可用,请尝试github安装源!!!
git clone https://gitee.com/mo2/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
 
git clone https://gitee.com/yantaozhao/zsh-autosuggestions.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
 
git clone https://gitee.com/wangnd/zsh-completions.git ${ZSH_CUSTOM:=~/.oh-my-zsh/custom}/plugins/zsh-completions
vim ~/.zshrc
plugins=(git zsh-completions zsh-autosuggestions zsh-syntax-highlighting)
source .zshrc

 清华大学开源软件镜像站