-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnew -- summarize PSReadlineKey bindings.ps1
45 lines (36 loc) · 1.27 KB
/
new -- summarize PSReadlineKey bindings.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
function _summarizeKeybind {
<#
.synopsis
make testing keybindings readable for the cli
.example
PS> _summarizeKeybind '^f\d$'
F1 = ShowCommandHelp; F2 = SwitchPredictionView; F3 = CharacterSearch; F8 = HistorySearchBackward
PS> _summarizeKeybind 'enter'
Alt+Enter = InsertLineBelow; Ctrl+Enter = InsertLineAbove; Enter = AcceptLine; Shift+Ctrl+Enter = InsertLineBelow; Shift+Enter = AddLine
#>
[Alias('__Refactor.ForTypeWriter')]
param(
# Regex
[Parameter(Position = 0)]
[string]$PatternKeybind
)
begin {
$splat_JoinKeys = @{
Separator = '; '
OutputSuffix = "`n"
Property = { $_.Key, $_.Function -join ' = ' }
}
}
process {
Label 'Pattern' $PatternKeybind | Write-Information
Get-PSReadLineKeyHandler -Bound
| Where-Object { $_.Key -match $PatternKeybind }
| Sort-Object Key
| Join-String @splat_JoinKeys
}
}
_summarizeKeybind '^f\d$' -InformationAction Continue
_summarizeKeybind 'enter' -InformationAction Continue
# Get-PSReadLineKeyHandler -Bound | Where-Object { $_.Key -match 'f[12]' }
# | Sort-Object Key
# | Join-String -sep '; ' { $_.Key, $_.Function -join ' = ' } -os ''