1. 安装 Homebrew
直接通过官网安装。打开Terminal,然后输入以下命令来安装 Homebrew。
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
安装完成后,按照提示将 Homebrew 添加到你的PATH环境变量中。类似下图
2. 使用 Homebrew 安装工具
2.1. 安装 iTerm2
打开 Terminal,然后输入以下命令来安装 iTerm2
brew install --cask iterm2
安装成功!
设置 iTerm2 主题为 Dracula
- iTerm2 > Settings > Profiles > Colors Tab;
- Open the Color Presets... drop-down in the bottom right corner;
- Select Import... from the list;
- Select the
Dracula.itermcolorsfile; - Select the Dracula from Color Presets... . 💜
接下来使用 iTerm2 安装!!!
2.2. 安装 zsh 和 Oh My Zsh
2.2.1 安装 Zsh:
brew install zsh
输入zsh --version,如果显示版本号则安装成功。
2.2.2 安装 Oh My Zsh:
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
出现下图则说明安装成功
安装 zsh 插件
安装和配置 zsh 插件可以显著提高你的开发效率和终端体验。以下是一些流行且实用的 zsh 插件:
1. zsh-syntax-highlighting
用于为命令提供语法高亮,使输入的命令更易读。
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $ZSH/custom/plugins/zsh-syntax-highlighting
2. zsh-autosuggestions
提供命令自动补全建议,根据你以前输入的命令给出建议。
git clonehttps://github.com/zsh-users/zsh-autosuggestions.git $ZSH/custom/plugins/zsh-autosuggestions
3. zsh-completions
扩展 zsh 的自动补全功能,提供对许多额外命令的补全支持。
git clonehttps://github.com/zsh-users/zsh-completions.git $ZSH/custom/plugins/zsh-completions
在 ~/.zshrc 中添加
plugins=(git zsh-syntax-highlighting zsh-autosuggestions zsh-completions)
2.3 安装 nvm 和 node
2.3.1 安装 nvm
使用 Homebrew 安装 nvm:
brew install nvm
创建 nvm 的工作目录:
mkdir ~/.nvm
将以下行添加到 ~/.zshrc 文件中:
export NVM_DIR="$HOME/.nvm"
[ -s "$(brew --prefix nvm)/nvm.sh" ] && \. "$(brew --prefix nvm)/nvm.sh"
应用更改:
source ~/.zshrc
2.3.2 安装 Node.js
使用 nvm 安装 Node.js
# 安装 Node.js 版本
nvm install <version>
nvm install 18.0.0
nvm install 18
# 安装 LTS 版本的 Node.js
nvm install --lts
# 查看已安装的 Node.js 版本
nvm ls
# 查看可用的 Node.js 版本
nvm ls-remote
# 使用指定的 Node.js 版本
nvm use <version>
nvm use 18.0.0
nvm use 18
# 设置默认 Node.js 版本
nvm alias default <version>
nvm alias default 18.0.0
nvm alias default 18
# 卸载 Node.js 版本
nvm uninstall <version>
nvm uninstall 18.0.0
# 列出所有已安装的 Node.js 版本(包括系统版本)
nvm ls
# 列出所有可用的 Node.js 版本
nvm ls-remote
# 查看当前使用的 Node.js 版本
nvm current