Skip to content

Instantly share code, notes, and snippets.

@bielawb
Created May 5, 2019 21:57
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 bielawb/8a691c44665dd9f41475290eeab90242 to your computer and use it in GitHub Desktop.
Save bielawb/8a691c44665dd9f41475290eeab90242 to your computer and use it in GitHub Desktop.
PSReadLine AutoHotKey implementation
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