【问题标题】:Can PowerShell Core use Windows Terminal instead of the pwsh.exe console?PowerShell Core 可以使用 Windows 终端而不是 pwsh.exe 控制台吗?
【发布时间】:2020-05-06 16:21:12
【问题描述】:

默认的 PowerShell Core (pwsh.exe) 控制台看起来就像命令提示符 (cmd.exe) 控制台。此外,PowerShell Core 控制台也有同样的限制,即不能正确显示外来字符(例如:韩语、日语等),除非我更改了我不想这样做的字体。另一方面,Windows Terminal 可以正常显示外来字符,因为它默认使用 UTF-8。

我使用 AutoHotKey 启动 PowerShell 脚本 (.ps1),我想知道是否可以在 Windows 终端中打开该脚本并自动使用 PowerShell Core?我需要进行任何配置更改吗?

【问题讨论】:

    标签: powershell-core windows-terminal


    【解决方案1】:

    是的,您可以执行类似的操作,启动 Windows 终端并在您的配置中添加 PowerShell 核心作为默认值,可以使用 crtl+, 键访问您只需将 defaultProfile 的 id 更改为 power shell 的一种形式核心。

    下面的例子:

    {
    "$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 设置按钮编辑
    猜你喜欢
    • 2022-12-31
    • 2019-12-13
    • 1970-01-01
    • 1970-01-01
    • 2021-02-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多