Workaround C-{ not being escape with PSReadLine 2.1

This commit is contained in:
Kenneth Benzie 2022-02-08 23:06:33 +00:00
parent 132696d34e
commit 0b89942f9d

View File

@ -14,27 +14,26 @@ Set-PSReadLineOption -BellStyle None -EditMode Vi
Set-PSReadLineKeyHandler -Chord Ctrl+w -Function BackwardDeleteWord Set-PSReadLineKeyHandler -Chord Ctrl+w -Function BackwardDeleteWord
# TODO: Doesn't work with PSReadLine 2.1 # TODO: Doesn't work with PSReadLine 2.1
# Hoping this gets fixed at some point and will just start working. # Hoping this gets fixed at some point and will just start working.
Set-PSReadLineKeyHandler -Chord Ctrl+[ -Function ViCommandMode # Set-PSReadLineKeyHandler -Chord Ctrl+[ -Function ViCommandMode
# Workaround is to use C-i instead, which is fitting with Vi I guess. # Workaournd from https://github.com/PowerShell/PSReadLine/issues/906#issuecomment-916847040
# TODO: Remove C-i if C-[ gets fixed. Set-PSReadLineKeyHandler -Chord 'Ctrl+Oem4' -Function ViCommandMode
Set-PSReadLineKeyHandler -Chord Ctrl+i -Function ViCommandMode
# # Change cursor shape based on what Vi mode the line editor is in. # Change cursor shape based on what Vi mode the line editor is in.
# # Testing and works with PowerShell 5.1 # Testing and works with PowerShell 5.1
# # NOTE: Requires: Install-Module PsReadline -Scope CurrentUser -Force # NOTE: Requires: Install-Module PsReadline -Scope CurrentUser -Force
# # FIXME: Doesn't work with PSReadLine 2.0 # FIXME: Doesn't work with PSReadLine 2.0
# function OnViModeChange { function OnViModeChange {
# if ($args[0] -eq 'Command') { if ($args[0] -eq 'Command') {
# # Set the cursor to non-blinking block. # Set the cursor to non-blinking block.
# Write-Host -NoNewLine "$([char]0x1b)[2 q" Write-Host -NoNewLine "$([char]0x1b)[2 q"
# } else { } else {
# # Set the cursor to non-blinking line. # Set the cursor to non-blinking line.
# Write-Host -NoNewLine "$([char]0x1b)[6 q" Write-Host -NoNewLine "$([char]0x1b)[6 q"
# } }
# } }
# Set-PSReadLineOption -ViModeIndicator Script -ViModeChangeHandler $Function:OnViModeChange Set-PSReadLineOption -ViModeIndicator Script -ViModeChangeHandler $Function:OnViModeChange
# # And set the cursor to a non-blinking line on profile load. # And set the cursor to a non-blinking line on profile load.
# Write-Host -NoNewLine "$([char]0x1b)[6 q" Write-Host -NoNewLine "$([char]0x1b)[6 q"
# Remove these aliases to PowerShell builtins which clobber the actaul exes. # Remove these aliases to PowerShell builtins which clobber the actaul exes.
Remove-Item alias:curl Remove-Item alias:curl