Get-PSReadLineKeyHandler:找不到与参数名称“Key”匹配的参数。《Oh My Posh》中的这个是什么?

Bip*_* Hf 4 powershell psreadline oh-my-posh

Get-PSReadLineKeyHandler : A parameter cannot be found that matches parameter name 'Key'.
At line:380 char:43
+             if ((Get-PSReadLineKeyHandler -Key Spacebar).Function -eq ...
+                                           ~~~~
    + CategoryInfo          : InvalidArgument: (:) [Get-PSReadLineKeyHandler], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.GetKeyHandlerCommand

Get-PSReadLineKeyHandler : A parameter cannot be found that matches parameter name 'Key'.
At line:383 char:43
+             if ((Get-PSReadLineKeyHandler -Key Enter).Function -eq 'O ...
+                                           ~~~~
    + CategoryInfo          : InvalidArgument: (:) [Get-PSReadLineKeyHandler], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.GetKeyHandlerCommand
Run Code Online (Sandbox Code Playgroud)

每当我打开 powershell 时都会出现此信息。我可以做什么来解决这个问题?

寻找解决方案。

小智 17

您需要更新 PSReadLine 模块。跑步:

Install-Module PsReadLine -Force
Run Code Online (Sandbox Code Playgroud)


小智 8

我有同样的问题。当我尝试在 $profile 的 oh-my-posh init 行中更改我的主题时,就发生了这种情况。运行Install-Module PsReadLine -Force修复了错误,但我的主题仍然没有改变。编辑 $PROFILE 时请确保输入

oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH/ENTER-THEME-NAME-HERE.omp.json" | Invoke-Expression

并不是

oh-my-posh init pwsh --config "~/ENTER-THEME-NAME-HERE.omp.json" | Invoke-Expression

Powershell选项卡下Config语法段落下页面错误。

希望这可以帮助。