powershellwindows-subsystem-for-linuxwindows-terminalpsreadline

Use the same keyboard shortcuts as Windows on Linux


I've installed Powershell on Ubuntu 24.04 (WSL), but I'm disappointed to find the shortcuts do not match the ones found on Windows (other options as well do not match, such as the completion style not cycling between options on repeated TAB like it does on Windows). Is there a way I can configure my Ubuntu PowerShell installation to follow Windows behaviour (without manually copying over Get-PSReadLineKeyHandler entries into my Ubuntu $PROFILE line by line)?

I am using Windows Terminal.

For reference, here is the result of Get-PSReadLineKeyHandler when run on both platforms:


Solution

  • The (initial) set of key bindings (keyboard shortcuts) is implied by the PSReadLine module's edit mode, whose default value differs by platform: Windows on Windows, and Emacs on Unix-like platforms.

    Thus, to get the same key bindings as on Windows on Unix-like platforms, place the following Set-PSReadLineOption call in your $PROFILE file (to ensure that it takes effect in all future sessions):

    Set-PSReadLineOption -EditMode Windows
    

    To see the edit mode currently in effect, call Get-PSReadLineOption as follows, though note that the initial set of bindings as implied by the active edit mode may have been modified later via Set-PSReadLineKeyHandler calls:

    (Get-PSReadLineOption).EditMode