如何配置 Windows 终端以使用不同于我的标准的单独配置文件启动 Powershell$Profile
这将有助于导入模块,例如posh-git
并且psreadline
仅在我启动的 Powershell 实例中,wt.exe
而不是从pwsh.exe
如何配置 Windows 终端以使用不同于我的标准的单独配置文件启动 Powershell$Profile
这将有助于导入模块,例如posh-git
并且psreadline
仅在我启动的 Powershell 实例中,wt.exe
而不是从pwsh.exe
您可以在调用时获取自定义 Powershell( .ps1
) 配置文件pwsh.exe
或powershell.exe
从wt.exe
. 例如posh-git
,Windows 终端 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
},
您可以通过[guid]::NewGuid()
在 Powershell 中运行命令为添加的每个新配置文件生成唯一的 guid。
最后,您专用的 Powershell 配置文件:C:/PsProfilePoshGit.ps1
看起来像这样(至少):
Import-Module posh-git
function global:prompt
{
Write-Host -Object "Posh-Git" -NoNewline -ForegroundColor Magenta
return "> "
}