Created
October 24, 2024 19:23
-
-
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
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
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