You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在PSReadLine中查询指定函数绑定的快捷键?

查看PSReadLine指定函数绑定的快捷键

在PowerShell 7.2.11搭配PSReadLine 2.2.2的环境中,没有专门的快捷键实现反向查询,但可以通过PowerShell命令完成需求,核心是使用Get-PSReadLineKeyHandler结合过滤条件:

基本用法

将<目标函数名>替换为你要查询的函数,执行以下命令:

Get-PSReadLineKeyHandler | Where-Object Function -eq '<目标函数名>'

示例1:查看BackwardDeleteChar的绑定快捷键

执行命令:

Get-PSReadLineKeyHandler | Where-Object Function -eq 'BackwardDeleteChar'

输出结果:

Key       Function           Description
---       --------           -----------
Backspace BackwardDeleteChar Delete the character before the cursor
Ctrl+h    BackwardDeleteChar Delete the character before the cursor

示例2:查看MenuComplete的绑定快捷键

执行命令:

Get-PSReadLineKeyHandler | Where-Object Function -eq 'MenuComplete'

输出结果:

Key           Function            Description
---           --------            -----------
Ctrl+@        MenuComplete        Complete the input if there is a single completion, otherwise show the menu
Ctrl+Spacebar MenuComplete        Complete the input if there is a single completion, otherwise show the menu

如果想一次性查看所有函数的绑定并按函数分组,可以用Group-Object整理输出:

Get-PSReadLineKeyHandler | Group-Object Function | ForEach-Object {
    Write-Host "`n=== $($_.Name) ==="
    $_.Group | Select-Object Key, Description
}

内容的提问来源于stack exchange,提问作者Jason Doyle

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.15 18:22:06