Created
April 11, 2021 15:07
-
-
Save rbleattler/948cf9576054d6198a497889701390b1 to your computer and use it in GitHub Desktop.
Allows the Import and Export of PSReadLineKeyHandlerSettings in JSON format (to be expanded in the future)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Function Import-PSReadLineKeyHandlerSettings { | |
| param( | |
| [Parameter(Mandatory)] | |
| [string] | |
| $Path | |
| ) | |
| begin { | |
| $ObjectToProcess = Get-Content $Path -Raw | ConvertFrom-Json | |
| } | |
| process { | |
| $ObjectToProcess.ForEach{ | |
| Set-PSReadLineKeyHandler -Function ($PSitem.Function) -Chord ($PSitem.Key) | |
| } | |
| } | |
| end { | |
| } | |
| } | |
| Function Export-PSReadLineKeyHandlerSettings { | |
| param( | |
| [Parameter(Mandatory)] | |
| [string] | |
| $Path | |
| ) | |
| begin { | |
| $PSReadLineKeyHandlerSettings = Get-PSReadLineKeyHandler | ConvertTo-Json -Depth 3 -Compress | |
| } | |
| process { | |
| Set-Content -Path $Path -Value $PSReadLineKeyHandlerSettings | |
| } | |
| end { | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment