Windows Termianl美化

Windows Termianl 是一款新的Windows 终端软件,不仅从外观、速度上都比 CMD 耐看,好用,而且进过一翻折腾之后,可以实现类似 Linux 系统下的 ZSH + Oh my ZSH 的效果。


Windows Termianl 美化

安装 Windows Termianl

推荐从Microsoft Store安装Windows Termianl ,因为通过商店安装方便,而且可自动在商店更新Windows Termianl。

安装 PowerShell


预览版和发行版都可以下载,我下载的是发行版,目前版本是v7.1.3 Release of PowerShell


安装 Oh my Posh

Oh my Posh 是一款可以给 Shell 提供主题引擎,类似 Oh my Zsh



在安装这个引擎之前,还需要安装一个包 Scoop

  1. 打开 Windows Termianl,执行下面命令,安装Scoop

    Invoke-Expression (New-Object System.Net.WebClient).DownloadString('')
  2. 安装 Oh my Posh

    scoop install
  3. 升级 Oh my Posh,如果用的到的话

    scoop update oh-my-posh
  4. 安装字体 [Meslo LGM NF](,这是里为了不乱码


配置 Windows Termianl



Windows Termianl 配置


Windows Termianl 是一个 Json 文件

  1. 找到profiles/list数组里面的数据,找到"name": "PowerShell"的记录,添加下面的配置进去

    // 不显示之类的信息: Type 'help' to get help.
    "commandline": "C:/Program Files/PowerShell/7-preview/pwsh.exe -nologo",
    // 使用上面安装的字体
    "fontFace": "MesloLGM NF"
  2. 在当前的数据体里,找到键名为"guid"的值,复制。替换掉第11行左右的,键名为defaultProfile的值


// This file was initially generated by Windows Terminal 1.0.1401.0
// It should still be usable in newer versions, but newer versions might have additional
// settings, help text, or changes that you will not see unless you clear this file
// and let us generate a new one for you.

// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see:
    "$schema": "",

    "defaultProfile": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",

    // You can add more global application settings here.
    // To learn more about global settings, visit

    // If enabled, selections are automatically copied to your clipboard.
    "copyOnSelect": false,

    // If enabled, formatted data is also copied to your clipboard
    "copyFormatting": false,

    // A profile specifies a command to execute paired with information about how it should look and feel.
    // Each one of them will appear in the 'New Tab' dropdown,
    //   and can be invoked from the commandline with `wt.exe -p xxx`
    // To learn more about profiles, visit
            // Put settings here that you want to apply to all profiles.
                // Make changes here to the powershell.exe profile.
                "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
                "name": "Windows PowerShell",
                "commandline": "powershell.exe",
                "hidden": false
                // Make changes here to the cmd.exe profile.
                "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
                "name": "命令提示符",
                "commandline": "cmd.exe",
                "hidden": false
                "guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
                "hidden": false,
                "name": "Azure Cloud Shell",
                "source": "Windows.Terminal.Azure"
                "guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
                "hidden": false,
                "name": "PowerShell",
                "source": "Windows.Terminal.PowershellCore",
                // 不显示之类的信息: Type 'help' to get help.
                "commandline": "C:/Program Files/PowerShell/7-preview/pwsh.exe -nologo",
                // 字体
                "fontFace": "MesloLGM NF"
                "guid": "{a3a2e83a-884a-5379-baa8-16f193a13b21}",
                "hidden": false,
                "name": "PowerShell 7 Preview",
                "source": "Windows.Terminal.PowershellCore"

    // Add custom color schemes to this array.
    // To learn more about color schemes, visit
    "schemes": [],

    // Add custom keybindings to this array.
    // To unbind a key combination from your defaults.json, set the command to "unbound".
    // To learn more about keybindings, visit
        // Copy and paste are bound to Ctrl+Shift+C and Ctrl+Shift+V in your defaults.json.
        // These two lines additionally bind them to Ctrl+C and Ctrl+V.
        // To learn more about selection, visit
        { "command": {"action": "copy", "singleLine": false }, "keys": "ctrl+c" },
        { "command": "paste", "keys": "ctrl+v" },

        // Press Ctrl+Shift+F to open the search box
        { "command": "find", "keys": "ctrl+shift+f" },

        // Press Alt+Shift+D to open a new pane.
        // - "split": "auto" makes this pane open in the direction that provides the most surface area.
        // - "splitMode": "duplicate" makes the new pane use the focused pane's profile.
        // To learn more about panes, visit
        { "command": { "action": "splitPane", "split": "auto", "splitMode": "duplicate" }, "keys": "alt+shift+d" }


在 Windows Termianl 执行下面命令

notepad.exe $PROFILE


Set-PoshPrompt PowerLine
Set-PSReadLineKeyHandler -Key "Tab" -Function MenuComplete
Set-PSReadLineKeyHandler -Key "Ctrl+z" -Function Undo
Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward
Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward


  1. 设置 Oh my Posh 主题为 PowerLine
  2. Table 键自动完成
  3. Ctrl+z 键撤销
  4. 键找回当前命令之前历史命令
  5. 键找回当前命令之后历史命令

最后关闭 Windows Termianl 再打开,效果就和效果图一致了。

修改Oh my Posh主题

修改主题也很简单,重复上个步骤,修改 Set-PoshPrompt 后面的值为对应的主题即可。

执行下面命令,可以查看Oh my Posh有什么主题。