本文章首发于语雀!
通过各种高科技功能同步到Hajeekn 的博客
⚠ 本文章仅适用于 - Windows 10(未精简版)
先放上我的图~
image.png
oh,看起来是不是很美妙呢?
让我们开始吧~~~~ 1.下载并安装 Windows Terminal / Powershell(7)
首先,我们需要下载 Windows Terminal
打开 Windows 10 Microsoft Store
在搜索框搜索 Windows Terminal
image.png
进入这个应用卡片(Windows Terminal / Windows Terminal Pre 版)
安装它~
安装完成 Windows Terminal 后就可以进入下一步 - 安装 Powershell
注意了,这里指的 Powershell 可不是那个蓝蓝的玩意儿
image.png
你猜对了,不是上面这个奇怪的玩意儿,而是 Powershell 7(新版)
| 首先声明,我们这儿用的 Powershell 与 Windows 自带的 Powershell 是完全不同的两个东西,除了功能相似和名字相同,两者内在已经天差地别。| (声明来自康佬~)
首先我们前去 Powershell 7 的GitHub 页面
随便下载一个版本,下载完成后安装就是了。 2. 安装字体
然后我们安装一个字体
这边笔者采用了Fira Code 3. 安装插件
这边我推荐的插件如下:

  • PSReadLine
  • oh-my-posh
  • posh-git

作用介绍:
(PSReadLine):
PSReadLine 是一个由微软发布的用于 PowerShell 的行读取实现,提供了以下功能:

  • 语法着色
  • 简单语法错误通知
  • 良好的多行体验
  • 可自定义的键绑定
  • Cmd 和 Emacs 模式
  • 许多配置选项
  • Bash 样式的补全
  • Bash/zsh 样式的交互式历史记录搜索
  • Emacs yank/kill ring
  • 基于 PowerShell Token 的单词移动和删除
  • 撤销 / 重做
  • 自动保存历史记录,包括在实时会话中共享历史记录
  • 菜单补全、Intellisense

(oh-my-posh / posh-git):

  • 类似于 oh-my-zsh,oh-my-posh 为 PowerShell 提供了很多自定义主题和配色,而 posh-git 为 PowerShell 提供了 git 状态显示和命令补全等。

看完上边的三个插件介绍,我们来安装这三个插件。
用管理员模式打开刚装好的新版 powershell,输入命令。
Install-Module -Name PSReadLine -AllowPrerelease -Force
Install-Module posh-git -Scope CurrentUser
Install-Module oh-my-posh -Scope CurrentUser

一定要用刚刚安装的新版的 powershell,安装过程可能过于慢,请耐心等待。
后面两个包的来源可能不受系统信任,不用管它,如果让你选择是否信任,直接输入 Y 即可。 4. 编辑 $Profile 文件
在命令行输入以下命令:
notepad.exe $Profile

如果提示不存在就直接创建
在内部写入以下代码:
Import-Module posh-git # 引入 posh-git
Import-Module oh-my-posh # 引入 oh-my-posh

Set-Theme Paradox # 设置主题为 Paradox

Set-PSReadlineKeyHandler -Key Tab -Function Complete # 设置 Tab 键补全
Set-PSReadLineKeyHandler -Key “Ctrl+d” -Function MenuComplete # 设置 Ctrl+d 为菜单补全和 Intellisense
Set-PSReadLineKeyHandler -Key “Ctrl+z” -Function Undo # 设置 Ctrl+z 为撤销
Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward # 设置向上键为后向搜索历史记录
Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward # 设置向下键为前向搜索历史纪录

**oh-my-posh 提供了 10 款 漂亮 的主题供我们选择。 Agnoster,Avit,Darkblood,Fish,Honukai,Paradox,PowerLine,robbyrussell,Sorin,tehrob**5. 接下来打开 > Windows Terminal
Windows Terminal 默认为旧版本的 powershell,我们需要把新版本作为默认。

修改的内容有三个,如果你不想自己改可以直接将我的粘贴到配置文件(需要注意的是:你的 commandline,如果按照默认路径安装(预览版),那么可以直接复制下边。正式版或者更换了安装位置,那么请手动更改位置。其他信息试自己能力进行修改)。
// 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: https://aka.ms/terminal-documentation
{
    “$schema”: “https://aka.ms/terminal-profiles-schema",

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

// You can add more global application settings here.
    // To learn more about global settings, visit https://aka.ms/terminal-global-settings

// 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 https://aka.ms/terminal-profile-settings
    “profiles”: {
        “defaults”: {
            // Put settings here that you want to apply to all profiles.
        },
        “list”: [
            {
                // 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”
            },
            {
                // Powershell 7 配置
                “guid”: “{574e775e-4f2a-5b96-ac1e-a2962a402336}”,
                “hidden”: false,
                “name”: “pwsh”,
                // 注意:一定要写上 -nologo,否则开启 powershll 会有一段话输出,很讨厌!
                // 如果下载的是正是版,那么路径为:C:/Program Files/PowerShell/7/pwsh.exe -nologo
                “commandline”: “C:/Program Files/PowerShell/7-preview/pwsh.exe -nologo”,
                “source”: “Windows.Terminal.PowershellCore”,
                // 启动菜单一定要设置为 <.>,否则后面重要的一步将会无效!
                “startingDirectory”: “.”,
                // 字体
                “fontFace”: “Fira Code”,
                “fontSize”: 11,
                “historySize”: 9001,
                “padding”: “5, 5, 20, 25”,
                “snapOnInput”: true,
                “useAcrylic”: false,
                // 颜色
                “colorScheme”: “idleToes”
            }    ]
    },

// Add custom color schemes to this array.
    // To learn more about color schemes, visit https://aka.ms/terminal-color-schemes
    “schemes”: [
        {
            “name”: “Zenburn”,
            “black”: “#4d4d4d”,
            “red”: “#705050”,
            “green”: “#60b48a”,
            “yellow”: “#f0dfaf”,
            “blue”: “#506070”,
            “purple”: “#dc8cc3”,
            “cyan”: “#8cd0d3”,
            “white”: “#dcdccc”,
            “brightBlack”: “#709080”,
            “brightRed”: “#dca3a3”,
            “brightGreen”: “#c3bf9f”,
            “brightYellow”: “#e0cf9f”,
            “brightBlue”: “#94bff3”,
            “brightPurple”: “#ec93d3”,
            “brightCyan”: “#93e0e3”,
            “brightWhite”: “#ffffff”,
            “background”: “#3f3f3f”,
            “foreground”: “#dcdccc”
        },
        {
            “name”: “PencilDark”,
            “black”: “#212121”,
            “red”: “#c30771”,
            “green”: “#10a778”,
            “yellow”: “#a89c14”,
            “blue”: “#008ec4”,
            “purple”: “#523c79”,
            “cyan”: “#20a5ba”,
            “white”: “#d9d9d9”,
            “brightBlack”: “#424242”,
            “brightRed”: “#fb007a”,
            “brightGreen”: “#5fd7af”,
            “brightYellow”: “#f3e430”,
            “brightBlue”: “#20bbfc”,
            “brightPurple”: “#6855de”,
            “brightCyan”: “#4fb8cc”,
            “brightWhite”: “#f1f1f1”,
            “background”: “#212121”,
            “foreground”: “#f1f1f1”
        },
        {
            “name”: “Slate”,
            “black”: “#222222”,
            “red”: “#e2a8bf”,
            “green”: “#81d778”,
            “yellow”: “#c4c9c0”,
            “blue”: “#264b49”,
            “purple”: “#a481d3”,
            “cyan”: “#15ab9c”,
            “white”: “#02c5e0”,
            “brightBlack”: “#ffffff”,
            “brightRed”: “#ffcdd9”,
            “brightGreen”: “#beffa8”,
            “brightYellow”: “#d0ccca”,
            “brightBlue”: “#7ab0d2”,
            “brightPurple”: “#c5a7d9”,
            “brightCyan”: “#8cdfe0”,
            “brightWhite”: “#e0e0e0”,
            “background”: “#222222”,
            “foreground”: “#35b1d2”
        },
        {
            “name”: “OneHalfDark”,
            “black”: “#282c34”,
            “red”: “#e06c75”,
            “green”: “#98c379”,
            “yellow”: “#e5c07b”,
            “blue”: “#61afef”,
            “purple”: “#c678dd”,
            “cyan”: “#56b6c2”,
            “white”: “#dcdfe4”,
            “brightBlack”: “#282c34”,
            “brightRed”: “#e06c75”,
            “brightGreen”: “#98c379”,
            “brightYellow”: “#e5c07b”,
            “brightBlue”: “#61afef”,
            “brightPurple”: “#c678dd”,
            “brightCyan”: “#56b6c2”,
            “brightWhite”: “#dcdfe4”,
            “background”: “#282c34”,
            “foreground”: “#dcdfe4”
        },
        {
            “name”: “OneHalfLight”,
            “black”: “#383a42”,
            “red”: “#e45649”,
            “green”: “#50a14f”,
            “yellow”: “#c18401”,
            “blue”: “#0184bc”,
            “purple”: “#a626a4”,
            “cyan”: “#0997b3”,
            “white”: “#fafafa”,
            “brightBlack”: “#4f525e”,
            “brightRed”: “#e06c75”,
            “brightGreen”: “#98c379”,
            “brightYellow”: “#e5c07b”,
            “brightBlue”: “#61afef”,
            “brightPurple”: “#c678dd”,
            “brightCyan”: “#56b6c2”,
            “brightWhite”: “#ffffff”,
            “background”: “#fafafa”,
            “foreground”: “#383a42”
        },
        {
            “name”: “Material”,
            “black”: “#212121”,
            “red”: “#b7141f”,
            “green”: “#457b24”,
            “yellow”: “#f6981e”,
            “blue”: “#134eb2”,
            “purple”: “#560088”,
            “cyan”: “#0e717c”,
            “white”: “#efefef”,
            “brightBlack”: “#424242”,
            “brightRed”: “#e83b3f”,
            “brightGreen”: “#7aba3a”,
            “brightYellow”: “#ffea2e”,
            “brightBlue”: “#54a4f3”,
            “brightPurple”: “#aa4dbc”,
            “brightCyan”: “#26bbd1”,
            “brightWhite”: “#d9d9d9”,
            “background”: “#eaeaea”,
            “foreground”: “#232322”
        },
        {
            “name”: “MaterialDark”,
            “black”: “#212121”,
            “red”: “#b7141f”,
            “green”: “#457b24”,
            “yellow”: “#f6981e”,
            “blue”: “#134eb2”,
            “purple”: “#560088”,
            “cyan”: “#0e717c”,
            “white”: “#efefef”,
            “brightBlack”: “#424242”,
            “brightRed”: “#e83b3f”,
            “brightGreen”: “#7aba3a”,
            “brightYellow”: “#ffea2e”,
            “brightBlue”: “#54a4f3”,
            “brightPurple”: “#aa4dbc”,
            “brightCyan”: “#26bbd1”,
            “brightWhite”: “#d9d9d9”,
            “background”: “#232322”,
            “foreground”: “#e5e5e5”
        },
        {
            “name”: “Homebrew”,
            “black”: “#000000”,
            “red”: “#FC5275”,
            “green”: “#00a600”,
            “yellow”: “#999900”,
            “blue”: “#6666e9”,
            “purple”: “#b200b2”,
            “cyan”: “#00a6b2”,
            “white”: “#bfbfbf”,
            “brightBlack”: “#666666”,
            “brightRed”: “#e50000”,
            “brightGreen”: “#00d900”,
            “brightYellow”: “#e5e500”,
            “brightBlue”: “#0000ff”,
            “brightPurple”: “#e500e5”,
            “brightCyan”: “#00e5e5”,
            “brightWhite”: “#e5e5e5”,
            “background”: “#283033”,
            “foreground”: “#00ff00”
        },
        {
            “name”: “Breeze”,
            “black”: “#31363b”,
            “red”: “#ed1515”,
            “green”: “#11d116”,
            “yellow”: “#f67400”,
            “blue”: “#1d99f3”,
            “purple”: “#9b59b6”,
            “cyan”: “#1abc9c”,
            “white”: “#eff0f1”,
            “brightBlack”: “#7f8c8d”,
            “brightRed”: “#c0392b”,
            “brightGreen”: “#1cdc9a”,
            “brightYellow”: “#fdbc4b”,
            “brightBlue”: “#3daee9”,
            “brightPurple”: “#8e44ad”,
            “brightCyan”: “#16a085”,
            “brightWhite”: “#fcfcfc”,
            “background”: “#31363b”,
            “foreground”: “#eff0f1”
        },
        {
            “name”: “idleToes”,
            “black”: “#323232”,
            “red”: “#d25252”,
            “green”: “#7fe173”,
            “yellow”: “#ffc66d”,
            “blue”: “#4099ff”,
            “purple”: “#f680ff”,
            “cyan”: “#bed6ff”,
            “white”: “#eeeeec”,
            “brightBlack”: “#535353”,
            “brightRed”: “#f07070”,
            “brightGreen”: “#9dff91”,
            “brightYellow”: “#ffe48b”,
            “brightBlue”: “#5eb7f7”,
            “brightPurple”: “#ff9dff”,
            “brightCyan”: “#dcf4ff”,
            “brightWhite”: “#ffffff”,
            “background”: “#323232”,
            “foreground”: “#00ff00”
        },
        {
            “name”: “Firewatch”,
            “black”: “#585f6d”,
            “red”: “#d95360”,
            “green”: “#5ab977”,
            “yellow”: “#dfb563”,
            “blue”: “#4d89c4”,
            “purple”: “#d55119”,
            “cyan”: “#44a8b6”,
            “white”: “#e6e5ff”,
            “brightBlack”: “#585f6d”,
            “brightRed”: “#d95360”,
            “brightGreen”: “#5ab977”,
            “brightYellow”: “#dfb563”,
            “brightBlue”: “#4c89c5”,
            “brightPurple”: “#d55119”,
            “brightCyan”: “#44a8b6”,
            “brightWhite”: “#e6e5ff”,
            “background”: “#1e2027”,
            “foreground”: “#9ba2b2”
        },
        {
            “name”: “Github”,
            “black”: “#3e3e3e”,
            “red”: “#970b16”,
            “green”: “#07962a”,
            “yellow”: “#f8eec7”,
            “blue”: “#003e8a”,
            “purple”: “#e94691”,
            “cyan”: “#89d1ec”,
            “white”: “#ffffff”,
            “brightBlack”: “#666666”,
            “brightRed”: “#de0000”,
            “brightGreen”: “#87d5a2”,
            “brightYellow”: “#f1d007”,
            “brightBlue”: “#2e6cba”,
            “brightPurple”: “#ffa29f”,
            “brightCyan”: “#1cfafe”,
            “brightWhite”: “#ffffff”,
            “background”: “#f4f4f4”,
            “foreground”: “#3e3e3e”
        }
    ],

// 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 https://aka.ms/terminal-keybindings
    “keybindings”: [
        // 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 https://aka.ms/terminal-selection
        { “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 https://aka.ms/terminal-panes
        {
            “command”: {
                “action”: “splitPane”,
                “split”: “auto”,
                “splitMode”: “duplicate”
            },
            “keys”: “alt+shift+d”
        }
    ]
}

  1. 配置鼠标右键
    完成上面的操作后,重新打开 Windows Terminal 就会发现模样已经变化了。

  2. 接下来就是配置鼠标右键了,添加鼠标右键的方式有两种,一种是用脚本,另一种就是改注册表。我本人比较推荐直接使用脚本,毕竟修改注册表有风险。。。

  3. 直接使用脚本

  4. 脚本下载地址:https://github.com/lextm/windowsterminal-shell/
    在 .\install.ps1 后面接参数可以定制你要的效果,该仓库提供了三个效果。如果不加参数,则使用默认效果。该仓库有个好处,那就是可以添加一个右键【以管理员身份在此打开】的选项,简便了不少。

  5. 再次使用管理员模式打开 PowerShell7,然后切换到放 install.ps1 的目录进行安装。我这里使用默认安装。如果你想用其他模式,也可以使用其他模式,看自己心情即可。其他模式请参考项目文档。


  1. 修改注册表。
  2. 自行百度
  3. 接下来我们到对应目录点击 pwsh 即可呼唤出新版的 powershell。