mac服务器配置
入职啦,村里又发 mac 了 记一下配置过程
终端
iTerm2
可以装个 iTerm2 替代初始的 terminal 虽然俺更喜欢 vsc 的终端
zsh
可以把 zsh 设置成默认的
chsh -s /bin/zsh然后开始装插件
# 美观的ohmyzsh
$ sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
# 自动补全
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
# 语法高亮检查
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting最后改一下~/.zshrc 的 plugin 部分
plugins=(git
    zsh-autosuggestions
    zsh-syntax-highlighting
    z)homebrew
安装
# 可以尝试使用国内镜像
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"咱们用的是 zsh,得在 zshrc 里配置一下
source /Users/bytedance/.profilegit
先生成 key 这里用的是 ed25519,比起 rsa 更安全、更快
ssh-keygen -t ed25519 -C "matto2024@163.com" # 把邮箱改成自己的git 一般是自带的 生成好主要是需要配置一下 ssh config 和 git config 前者用途是为不同的 Git 服务器(如 GitHub、GitLab、公司内部 Git)设置不同的 SSH 密钥 后者是配置 git 用户名和邮箱
~/.ssh/config 文件
Host github.com
    HostName github.com
    User git
    IdentityFile ~/.ssh/id_ed25519git config 配置
git config --global user.name "matto"
git config --global user.email "matto2024@163.com"最后是需要在对应的 git 服务器上添加 ssh 的 pub key
多个 git 用户信息的配置
然而有的时候我们针对公司内的 git 和 自己的 github 需要配置不同的用户信息 我们可以在 gitconfig 里面来进行匹配,完成配置
# 这一串设置通过匹配当前仓库的remote.origin.url 来决定使用哪个gitconfig
# 这里匹配的是github和gitlab的git和https前缀
[includeIf "hasconfig:remote.*.url:git@github.com:*/**"]
    path = ~/.gitconfig-personal
[includeIf "hasconfig:remote.*.url:https://github.com/**"]
    path = ~/.gitconfig-personal
[includeIf "hasconfig:remote.*.url:git@gitlab.company.com:*/**"]
    path = ~/.gitconfig-personal
[includeIf "hasconfig:remote.*.url:https://gitlab.company.com/**"]
    path = ~/.gitconfig-personal然后创建对应的 gitconfig-personal 文件
touch ~/.gitconfig-personal再在里面填入
[user]
    name = matto
    email = matto2023@163.com打开一个使用 github 的仓库,然后执行
git config user.name来看看有没有成功
前端环境
node
brew install fnm然后装 node
fnm install --lts会发现安装的 node 指令用不了 需要在.zshrc 里配置一下
# 基础配置 - 必需
eval "$(fnm env --use-on-cd)"
# 可选的额外配置
export PATH="/opt/homebrew/bin:$PATH"  # 确保 brew 安装的 fnm 在 PATH 中
# 自动完成配置(可选)
# 添加 fnm 的自动完成支持
eval "$(fnm completions --shell zsh)"
# 自动切换 node 版本(可选)
# 如果目录下有 .node-version 或 .nvmrc 文件,会自动切换到对应版本
eval "$(fnm env --use-on-cd)"