PowerShell Core能否使用Windows Terminal替代pwsh.exe控制台?

5

默认的PowerShell Core (pwsh.exe)控制台看起来和命令提示符(cmd.exe)控制台一样。此外,PowerShell Core控制台和命令提示符控制台有同样的限制,不能正确显示外文字符(例如:韩文、日文等),除非我改变字体,但我不想这么做。另一方面,Windows终端使用UTF-8作为默认编码,可以正确地显示外文字符。

我使用AutoHotKey启动一个PowerShell脚本(.ps1),我想知道是否可能让这个脚本在Windows终端中自动使用PowerShell Core打开?需要进行哪些配置更改吗?

1个回答

6

是的,您可以做类似的事情,启动Windows终端并将PowerShell Core作为默认配置添加到其中,在配置中可通过crtl+,快捷键访问,默认配置的ID可以使用PowerShell Core的ID来更改。

以下是示例:

{
"$schema": "https://aka.ms/terminal-profiles-schema",

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

"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": "cmd",
            "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"
        }
    ]
},

在 Windows 11 上需要浏览 UI 直到找到 JSON 设置按钮进行编辑。 - Dzmitry Lahoda
我的电脑中没有Windows Powershell配置文件。我已经安装了Powershell 7... - jjxtra

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接