-
-
Save bielawb/8a691c44665dd9f41475290eeab90242 to your computer and use it in GitHub Desktop.
PSReadLine AutoHotKey implementation
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
Set-PSReadlineKeyHandler -Chord Spacebar -ScriptBlock { | |
param ($key, $arg) | |
$psReadLine = [Microsoft.PowerShell.PSConsoleReadLine] | |
$convert = @{ | |
'co' = 'git commit ' | |
'ad' = 'git add ' | |
'pu' = 'git push ' | |
'me' = 'git merge ' | |
} | |
$line = $null | |
$cursor = $null | |
$psReadLine::GetBufferState( | |
[ref]$line, [ref]$cursor | |
) | |
if ($convert.ContainsKey($line)) { | |
$psReadLine::Replace( | |
0, | |
$line.Length, | |
$convert.$line | |
) | |
$psReadLine::SetCursorPosition($convert.$line.Length) | |
} else { | |
$psReadLine::Insert(' ') | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment