Skip to content

Instantly share code, notes, and snippets.

@jbirley
Created September 9, 2020 16:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbirley/19fe57c4e95377c9aedba4e6d7565fac to your computer and use it in GitHub Desktop.
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.
$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