Created
September 9, 2020 16:44
-
-
Save jbirley/19fe57c4e95377c9aedba4e6d7565fac to your computer and use it in GitHub Desktop.
PsReadlineKeyHandler to put parenthesis around the entire line and move the cursor to the end of line.
This file contains 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
$ScriptBlock = { | |
param($Key, $Arg) | |
$Line = $null | |
$Cursor = $null | |
[Microsoft.PowerShell.PSConsoleReadLine]::GetBufferState([ref]$Line, [ref]$Cursor) | |
[Microsoft.PowerShell.PSConsoleReadLine]::Replace(0, $Line.Length, '(' + $Line + ')') | |
[Microsoft.PowerShell.PSConsoleReadLine]::EndOfLine() | |
} | |
$Splat = @{ | |
BriefDescription = 'ParenthesizeLine' | |
LongDescription = 'Put parenthesis around the entire line and move the cursor to the end of line.' | |
ScriptBlock = $ScriptBlock | |
} | |
Set-PSReadlineKeyHandler -Key 'Ctrl+p' @Splat |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment