Windows Terminal

Windows Terminal 是微软官方推出的现代终端应用,支持多标签页、分屏、GPU 加速渲染,可同时托管 PowerShell、CMD、WSL、SSH 等多种 Shell。

界面布局

┌─────────────────────────────────────────────────┐
│  标签栏  [PowerShell] [CMD] [Ubuntu] [+]  [≡]   │
├─────────────────────────────────────────────────┤
│                                                 │
│               终端内容区                         │
│                                                 │
│  ┌──────────────┬──────────────────────────┐    │
│  │  分屏窗格 1  │      分屏窗格 2           │    │
│  └──────────────┴──────────────────────────┘    │
└─────────────────────────────────────────────────┘

常用快捷键

操作快捷键
新建标签页Ctrl+Shift+T
关闭标签页Ctrl+Shift+W
切换标签页Ctrl+Tab / Ctrl+Shift+Tab
水平分屏Alt+Shift+-
垂直分屏Alt+Shift++
切换窗格Alt+方向键
打开设置Ctrl+,
全屏F11
放大字体Ctrl+=
缩小字体Ctrl+-
命令面板Ctrl+Shift+P

配置文件

配置保存在 settings.json,通过 Ctrl+, → 左下角”打开 JSON 文件”访问。

常用配置

{
    "defaultProfile": "{PowerShell 的 GUID}",
    "copyOnSelect": true,
    "confirmCloseAllTabs": false,
    "profiles": {
        "defaults": {
            "font": {
                "face": "CaskaydiaCove Nerd Font",
                "size": 13
            },
            "opacity": 95,
            "useAcrylic": true,
            "colorScheme": "One Half Dark"
        }
    }
}

启动目录设置

{
    "profiles": {
        "list": [
            {
                "name": "PowerShell",
                "startingDirectory": "%USERPROFILE%"
            }
        ]
    }
}

主题配色

内置主题:One Half DarkCampbellSolarized DarkTomorrow Night Blue 等。

自定义主题写在 schemes 数组:

{
    "schemes": [
        {
            "name": "MyTheme",
            "background": "#1e1e2e",
            "foreground": "#cdd6f4",
            "black": "#45475a",
            "red": "#f38ba8"
        }
    ]
}

推荐主题集合:Catppuccin / Dracula

与 Oh My Posh 集成

Oh My Posh 为 PowerShell 提供 Prompt 美化。

# 安装
winget install JanDeLaater.OhMyPosh
 
# 安装 Nerd Font
oh-my-posh font install
 
# 在 PowerShell profile 中启用
notepad $PROFILE
# 添加:oh-my-posh init pwsh | Invoke-Expression

安装方式

# 通过 winget 安装(推荐)
winget install Microsoft.WindowsTerminal
 
# 或从 Microsoft Store 安装

相关文档