PSReadline
我使用模块将 Vim 绑定添加到我的 Powershell ,如服务器故障帖子中所示。之后的问题是 Vim 的不同模式没有任何视觉指示器。
我只是想要“命令”和其他模式的不同光标。命令模式的块光标和其他模式的行光标。所以我四处搜索,在微软官方文档中找到了这个:Use ViModeChangeHandler to display Vi mode changes
# This example emits a cursor change VT escape in response to a Vi mode change.
function OnViModeChange {
if ($args[0] -eq 'Command') {
# Set the cursor to a blinking block.
Write-Host -NoNewLine "`e[1 q"
} else {
# Set the cursor to a blinking line.
Write-Host -NoNewLine "`e[5 q"
}
}
Set-PSReadLineOption -ViModeIndicator Script -ViModeChangeHandler $Function:OnViModeChange
$PROFILE
我只是在运行后将其复制粘贴到我的文件底部ise $PROFILE
。
令人惊讶的是,当我尝试获取我的来源时出现错误$PROFILE
:
> & $PROFILE
Set-PSReadLineOption : Cannot bind parameter 'ViModeIndicator'. Cannot convert value "Script" to type
"Microsoft.PowerShell.ViModeStyle". Error: "Unable to match the identifier name Script to a valid enumerator name. Specify one of
the following enumerator names and try again:
None, Prompt, Cursor"
At C:\Users\user\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1:27 char:39
+ Set-PSReadLineOption -ViModeIndicator Script -ViModeChangeHandler $Fu ...
+ ~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-PSReadLineOption], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerShell.SetPSReadLineOption
谷歌搜索“Set-PSReadLineOption:无法绑定参数'ViModeIndicator'。无法将值“脚本”转换为类型“Microsoft.PowerShell.ViModeStyle”。” 不会产生任何有用的结果(实际上只有 2 个结果)。
我怎样才能解决这个问题?