Skip to content

Instantly share code, notes, and snippets.

@rbleattler
Created April 11, 2021 15:07
Show Gist options
  • Select an option

  • Save rbleattler/948cf9576054d6198a497889701390b1 to your computer and use it in GitHub Desktop.

Select an option

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)
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