Aya*_*Pal 3 powershell powershell-core windows-terminal
如何配置 Windows 终端以使用标准配置以外的单独配置文件启动 Powershell $Profile
这将有助于导入模块,例如posh-git并且psreadline仅在我启动的 Powershell 实例中,wt.exe而不是从pwsh.exe
您可以.ps1在调用pwsh.exe或powershell.exe从wt.exe. 例如posh-git,Windows Terminal settings.json 中的配置文件如下所示:
{
"guid": "{01463d52-dda9-4109-b03f-c55899b52df2}",
"name": "Powershell - Posh Git",
"commandline": "powershell.exe -noprofile -noexit -command \"invoke-expression '. ''C:/PsProfilePoshGit.ps1''' \"",
"icon": "ms-appx:///ProfileIcons/{61c54bbd-c2c6-5271-96e7-009a87ff44bf}.png",
"hidden": false
},
Run Code Online (Sandbox Code Playgroud)
通过[guid]::NewGuid()在 Powershell 中运行命令,您可以为添加的每个新配置文件生成唯一的 guid 。
最后,您的专用 Powershell 配置文件:C:/PsProfilePoshGit.ps1看起来像这样(至少):
{
"guid": "{01463d52-dda9-4109-b03f-c55899b52df2}",
"name": "Powershell - Posh Git",
"commandline": "powershell.exe -noprofile -noexit -command \"invoke-expression '. ''C:/PsProfilePoshGit.ps1''' \"",
"icon": "ms-appx:///ProfileIcons/{61c54bbd-c2c6-5271-96e7-009a87ff44bf}.png",
"hidden": false
},
Run Code Online (Sandbox Code Playgroud)