Get-PSReadLineKeyHandler : A parameter cannot be found that matches parameter name 'Key'. What is this in Oh My Posh?

huangapple go评论75阅读模式
英文:

Get-PSReadLineKeyHandler : A parameter cannot be found that matches parameter name 'Key'. What is this in Oh My Posh?

问题

Get-PSReadLineKeyHandler : 找不到与参数名 'Key' 匹配的参数。
在第380行的第43个字符:
+             if ((Get-PSReadLineKeyHandler -Key Spacebar).Function -eq ...
+                                           ~~~~
    + CategoryInfo          : InvalidArgument: (:) [Get-PSReadLineKeyHandler],ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.GetKeyHandlerCommand

Get-PSReadLineKeyHandler : 找不到与参数名 'Key' 匹配的参数。
在第383行的第43个字符:
+             if ((Get-PSReadLineKeyHandler -Key Enter).Function -eq 'O ...
+                                           ~~~~
    + CategoryInfo          : InvalidArgument: (:) [Get-PSReadLineKeyHandler],ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.GetKeyHandlerCommand

每次打开 PowerShell 时都会出现这个错误。您可以尝试以下方法来修复它。

英文:
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

This appears everytime whenever I open my powershell. What can I do to fix this?

Looking for a solution.

答案1

得分: 13

你需要更新 PSReadLine 模块。运行:

Install-Module PsReadLine -Force
英文:

You need to update the PSReadLine module. Run:

Install-Module PsReadLine -Force

答案2

得分: 6

我遇到了完全相同的问题。当我尝试在 $profile 中的 oh-my-posh 初始化行中更改主题时,出现了这个问题。 运行 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 选项卡下的“配置语法”段落下,该页面有错误。

希望这能帮到你。

英文:

I had the same exact issue. It occurred for me when trying to change my theme in the oh-my-posh init line in $profile. Running Install-Module PsReadLine -Force fixed the error, but my theme still didn't change. When editing $PROFILE make sure you put in

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

and not

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

The page is wrong under the powershell tab under the Config syntax paragraph.

Hope this helps.

huangapple
  • 本文由 发表于 2023年2月19日 16:57:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/75499007.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定