Skip to content

Instantly share code, notes, and snippets.

@dstcruz
Created October 24, 2024 19:23
Show Gist options
  • Save dstcruz/da1968b2a8c0dbc6a9d4cababeb8c832 to your computer and use it in GitHub Desktop.
Save dstcruz/da1968b2a8c0dbc6a9d4cababeb8c832 to your computer and use it in GitHub Desktop.
Powershell PSReadlLine keybinding for C-e to go to the end of the line if we are not there, or accept the autosuggestion if we are there
​Set-PsReadlineKeyHandler -Chord 'Ctrl+e' -ScriptBlock {
$line = $cursor = $null
[Microsoft.PowerShell.PSConsoleReadLine]::GetBufferState([ref] $line, [ref] $cursor)
if ($cursor -eq $line.Length) {
[Microsoft.PowerShell.PSConsoleReadLine]::AcceptSuggestion()
}
else {
[Microsoft.PowerShell.PSConsoleReadLine]::EndOfLine()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment