美化Windows Terminal
前置要求
- 操作系统:Windows 10 或 Windows 11
1. 安装 Windows Terminal 和 PowerShell
推荐通过 Scoop 安装(若未配置 Scoop 请先参考Scoop的安装与配置):
scoop install windows-terminal powershell更新 PowerShell 自身时,须用系统自带的 Windows PowerShell 执行,否则会因占用导致更新失败:
powershell"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -Command "scoop update powershell -g" // 如果使用了我的scoop安装配置,使用'scoop-update'
备选:从 Microsoft Store 搜索并安装这两个应用。
2. 修改配置
打开 Windows Terminal,在 Startup 选项卡中将默认配置文件改为新安装的 PowerShell。
点击左下角的 "Open JSON file" 按钮,在 defaults 节下添加以下配置:
// 启用亚克力模糊效果
"useAcrylic": true,
"acrylicOpacity": 0.2,
// 设置背景图片(将 URL 替换为本地图片路径,如 C:\\1.png)
"backgroundImage": "URL",
"backgroundImageOpacity": 0.4在 Windows Terminal 设置中,将 Default/PowerShell/Command Prompt 的字体改为 JetBrainsMonoNerdFontMono 或你喜欢的字体 字体下载链接
安装 oh-my-posh(推荐使用 Starship)
- 从 Windows Store 搜索安装,或使用此直接链接:
oh-my-posh 商店链接
- 安装完成后,修改启动脚本:
在 Windows Terminal 中运行:
powershell~~ ~~notepad $PROFILE~~ ~~
在文件中添加以下内容:
powershell~~ ~~oh-my-posh init pwsh --config $env:POSH_THEMES_PATH\montys.omp.json | Invoke-Expression~~ ~~
3. 安装 Starship
Starship 是一个用 Rust 编写的跨 Shell 提示符工具,极简、极快、高度可定制。
安装
通过 Scoop 安装(推荐),安装并配置 Scoop 请参考Scoop的安装与配置:
scoop install starship配置 PowerShell
在 PowerShell 中运行以下命令打开配置文件:
notepad $PROFILE在文件末尾添加以下内容:
Invoke-Expression (&starship init powershell)自定义主题
Starship 通过 ~/.config/starship.toml 配置,详细配置项参考官方文档。社区预设主题可参考 Starship Presets。
Starship 相比 oh-my-posh 的优势
- 性能优秀:Rust 编写,启动延迟远低于 oh-my-posh,实测 Profile 加载时间可降低 80% 以上
- 跨 Shell 统一:同一套配置在 PowerShell、Cmd、Bash、Zsh 等任何 Shell 下表现一致
- 模块化设计:按需启用模块,不会有冗余功能拖慢速度
4. 最后一步
重启 Windows Terminal,享受定制后的界面!