Feb-27, 2025 · 10min
change language完整的 Mac 开发环境初始化指南,包括 Homebrew 安装、Oh My Zsh 配置、Powerlevel10k 主题设置、VSCode 配置、Git 和 SSH 设置等
确保有良好的网络环境
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"这里安装完成后会需要执行几个命令设置环境变量,由对应的提示
克隆仓库
git clone https://github.com/ohmyzsh/ohmyzsh.git ~/.oh-my-zsh复制模板文件
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc重新加载配置
source ~/.zshrc克隆仓库
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k"在 .zshrc 中添加
ZSH_THEME="powerlevel10k/powerlevel10k"重新加载配置
source ~/.zshrc安装支持图标的字体文件
终端设置使用字体

自定义配置
p10k configure配置显示的数据
配置显示 node 版本号和 package.json 版本
vim ~/.p10k.zsh

安装 zsh 插件
zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestionszsh-syntax-highlighting
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting在 .zshrc 中添加
plugins=(
git
sudo
z
zsh-autosuggestions
zsh-syntax-highlighting
)完整文件 .zshrc, 文件名是 .zshrc
生成 ssh 密钥
ssh-keygen -m PEM -t ed25519 -C "your.email@example.com"查看 ssh 公钥
cat ~/.ssh/id_ed25519.pub全局用户名邮箱
git config --global user.name "Your Name"
git config --global user.email "email@example.com"当前仓库用户名邮箱
git config --local user.name "Your Name"
git config --local user.email "email@example.com"配置 quotepath 选项
避免中文路径乱码
git config --global core.quotepath false不忽略大小写
git config --global core.ignorecase false完整的配置 .gitconfig
[user]
name = "Your Name"
email = "email@example.com"
[core]
quotepath = false
ignorecase = false生成多个 ssh 密钥
ssh-keygen -m PEM -t ed25519 -C "your.email@example.com" -f ~/.ssh/id_ed25519ssh-keygen -m PEM -t ed25519 -C "your.email@example.com" -f ~/.ssh/id_ed25519_gitlab配置 ssh 配置文件
vim ~/.ssh/config完整的配置 .ssh/config
# Personal account, - the default config
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519
ProxyCommand nc -v -x 127.0.0.1:7890 %h %p
# Work account-1
Host gitlab.com
HostName gitlab.com
User git
IdentityFile ~/.ssh/id_ed25519_gitlabIdentityFile 为当前的 Host 配置 ssh 密钥
ProxyCommand 为 GitHub 仓库配置代理,使用 nc 命令,127.0.0.1:7890 是本机代理端口
仅在台前调度时,点击墙纸显示桌面

调整鼠标指针大小

关闭自动首字母大写

vim 设置键盘重复

全局打开键盘长按连续输入
defaults write -g ApplePressAndHoldEnabled -bool false