这份指南将带你从零开始,把 WezTerm 配置成一个既美观又实用的 Windows 生产力工具。
一、安装 WezTerm
https://wezterm.org/index.html
二、安装必备字体
为了确保终端内的图标和文字显示正常,建议安装 JetBrains Mono Nerd Font。
- 前往 Nerd Fonts 官网。
- 找到 JetBrainsMono Nerd Font,点击 Download。
- 解压下载的压缩包,全选所有的
.ttf文件,右键选择 “安装”(或“为所有用户安装”)。
三、安装 PowerShell 7
winget install --id Microsoft.Powershell --source winget
- 极快,启动速度和处理速度大幅提升
- 更好的错误提示
- PowerShell 5.1 默认使用
UTF-16或各种本地编码(如 GBK),这在运行像 Claude Code 这样基于 Node.js 的工具时,经常会导致乱码或奇怪的报错。PowerShell 7 默认原生支持 UTF-8,能完美显示各种图标和特殊符号。
四、安装 Starship
winget install starship
将 Starship 注入 PowerShell 7
修改 PowerShell 7 的配置文件,让它每次启动都加载 Starship。
操作步骤
- 创建并打开配置文件
if (!(Test-Path -Path $PROFILE)) { New-Item -ItemType File -Path $PROFILE -Force }
notepad $PROFILE
- 添加以下内容
Invoke-Expression (&starship init powershell)
function cc { claude --dangerously-skip-permissions $args }
- 保存并关闭记事本
- 刷新配置
. $PROFILE
或直接重启 WezTerm 生效。
说明: $PROFILE 变量指向 PowerShell 7 的配置文件路径 Documents\PowerShell\Microsoft.PowerShell_profile.ps1,与 Windows PowerShell 5.x 的配置文件是分开的。
五、创建并编辑配置文件
WezTerm 的所有设置都在一个 Lua 脚本中完成。
- 打开你的 文件资源管理器。
- 进入你的用户根目录(快捷路径:
%USERPROFILE%)。 - 在该目录下新建一个文件,命名为
.wezterm.lua(注意前面有个点)。 - 用记事本或 VS Code 打开它,粘贴以下配置:
local wezterm = require 'wezterm'
local config = wezterm.config_builder()
-- 指定默认使用 PowerShell 7 且隐藏启动日志_
config.default_prog = { 'pwsh.exe', '-NoLogo' }
config.color_scheme = 'Dracula'
config.font = wezterm.font 'JetBrainsMono Nerd Font'
config.font_size = 10
-- 开启一下渲染优化_
config.front_end = "WebGpu"
return config