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:
Windows
Basic editing functions
=======================
Key Function Description
--- -------- -----------
Enter AcceptLine Accept the input or move to the next line if input is missing a closing token.
Shift+Enter AddLine Move the cursor to the next line without attempting to execute the input
Backspace BackwardDeleteChar Delete the character before the cursor
Ctrl+h BackwardDeleteChar Delete the character before the cursor
Ctrl+Home BackwardDeleteInput Delete text from the cursor to the start of the input
Ctrl+Backspace BackwardKillWord Move the text from the start of the current or previous word to the cursor to the
kill ring
Ctrl+w BackwardKillWord Move the text from the start of the current or previous word to the cursor to the
kill ring
Ctrl+C Copy Copy selected region to the system clipboard. If no region is selected, copy the
whole line
Ctrl+c CopyOrCancelLine Either copy selected text to the clipboard, or if no text is selected, cancel
editing the line with CancelLine.
Ctrl+x Cut Delete selected region placing deleted text in the system clipboard
Delete DeleteChar Delete the character under the cursor
Ctrl+End ForwardDeleteInput Delete text from the cursor to the end of the input
Ctrl+Enter InsertLineAbove Inserts a new empty line above the current line without attempting to execute the
input
Shift+Ctrl+Enter InsertLineBelow Inserts a new empty line below the current line without attempting to execute the
input
Alt+d KillWord Move the text from the cursor to the end of the current or next word to the kill
ring
Ctrl+Delete KillWord Move the text from the cursor to the end of the current or next word to the kill
ring
Ctrl+v Paste Paste text from the system clipboard
Shift+Insert Paste Paste text from the system clipboard
Ctrl+y Redo Redo an undo
Escape RevertLine Equivalent to undo all edits (clears the line except lines imported from history)
Ctrl+z Undo Undo a previous edit
Alt+. YankLastArg Copy the text of the last argument to the input
Cursor movement functions
=========================
Key Function Description
--- -------- -----------
LeftArrow BackwardChar Move the cursor back one character
Ctrl+LeftArrow BackwardWord Move the cursor to the beginning of the current or previous word
Home BeginningOfLine Move the cursor to the beginning of the line
End EndOfLine Move the cursor to the end of the line
RightArrow ForwardChar Move the cursor forward one character
Ctrl+] GotoBrace Go to matching brace
Ctrl+RightArrow NextWord Move the cursor forward to the start of the next word
History functions
=================
Key Function Description
--- -------- -----------
Alt+F7 ClearHistory Remove all items from the command line history (not PowerShell history)
Ctrl+s ForwardSearchHistory Search history forward interactively
F8 HistorySearchBackward Search for the previous item in the history that starts with the current input - like
PreviousHistory if the input is empty
Shift+F8 HistorySearchForward Search for the next item in the history that starts with the current input - like
NextHistory if the input is empty
DownArrow NextHistory Replace the input with the next item in the history
UpArrow PreviousHistory Replace the input with the previous item in the history
Ctrl+r ReverseSearchHistory Search history backwards interactively
Completion functions
====================
Key Function Description
--- -------- -----------
Ctrl+@ MenuComplete Complete the input if there is a single completion, otherwise complete the input by
selecting from a menu of possible completions.
Ctrl+Spacebar MenuComplete Complete the input if there is a single completion, otherwise complete the input by
selecting from a menu of possible completions.
Tab TabCompleteNext Complete the input using the next completion
Shift+Tab TabCompletePrevious Complete the input using the previous completion
Prediction functions
====================
Key Function Description
--- -------- -----------
F4 ShowFullPredictionTooltip Show the full tooltip of the selected list-view item in the terminal's alternate screen
buffer.
F2 SwitchPredictionView Switch between the inline and list prediction views.
Miscellaneous functions
=======================
Key Function Description
--- -------- -----------
Ctrl+l ClearScreen Clear the screen and redraw the current line at the top of the screen
Alt+0 DigitArgument Start or accumulate a numeric argument to other functions
Alt+1 DigitArgument Start or accumulate a numeric argument to other functions
Alt+2 DigitArgument Start or accumulate a numeric argument to other functions
Alt+3 DigitArgument Start or accumulate a numeric argument to other functions
Alt+4 DigitArgument Start or accumulate a numeric argument to other functions
Alt+5 DigitArgument Start or accumulate a numeric argument to other functions
Alt+6 DigitArgument Start or accumulate a numeric argument to other functions
Alt+7 DigitArgument Start or accumulate a numeric argument to other functions
Alt+8 DigitArgument Start or accumulate a numeric argument to other functions
Alt+9 DigitArgument Start or accumulate a numeric argument to other functions
Alt+- DigitArgument Start or accumulate a numeric argument to other functions
PageDown ScrollDisplayDown Scroll the display down one screen
Ctrl+PageDown ScrollDisplayDownLine Scroll the display down one line
PageUp ScrollDisplayUp Scroll the display up one screen
Ctrl+PageUp ScrollDisplayUpLine Scroll the display up one line
F1 ShowCommandHelp Shows help for the command at the cursor in an alternate screen buffer.
Ctrl+Alt+? ShowKeyBindings Show all key bindings
Alt+h ShowParameterHelp Shows help for the parameter at the cursor.
Alt+? WhatIsKey Show the key binding for the next chord entered
Selection functions
===================
Key Function Description
--- -------- -----------
Ctrl+a SelectAll Select the entire line. Moves the cursor to the end of the line
Shift+LeftArrow SelectBackwardChar Adjust the current selection to include the previous character
Shift+Home SelectBackwardsLine Adjust the current selection to include from the cursor to the start of
the line
Shift+Ctrl+LeftArrow SelectBackwardWord Adjust the current selection to include the previous word
Alt+a SelectCommandArgument Make visual selection of the command arguments.
Shift+RightArrow SelectForwardChar Adjust the current selection to include the next character
Shift+End SelectLine Adjust the current selection to include from the cursor to the end of the
line
Shift+Ctrl+RightArrow SelectNextWord Adjust the current selection to include the next word
Search functions
================
Key Function Description
--- -------- -----------
F3 CharacterSearch Read a character and move the cursor to the next occurrence of that character
Shift+F3 CharacterSearchBackward Read a character and move the cursor to the previous occurrence of that character
Linux:
Basic editing functions
=======================
Key Function Description
--- -------- -----------
Ctrl+g Abort Abort the current operation, e.g. incremental history search
Ctrl+o AcceptAndGetNext Accept the current line and recall the next line from history after the current line finishes
executing
Enter AcceptLine Accept the input or move to the next line if input is missing a closing token.
Shift+Enter AddLine Move the cursor to the next line without attempting to execute the input
Backspace BackwardDeleteChar Delete the character before the cursor
Ctrl+Backspace BackwardDeleteChar Delete the character before the cursor
Ctrl+u BackwardKillInput Move the text from the cursor to the beginning of the input to the kill ring
Ctrl+x,Backspace BackwardKillInput Move the text from the cursor to the beginning of the input to the kill ring
Alt+Backspace BackwardKillWord Move the text from the start of the current or previous word to the cursor to the kill ring
Escape,Backspace BackwardKillWord Move the text from the start of the current or previous word to the cursor to the kill ring
Alt+c CapitalizeWord Find the next word starting from the current position and then upcase the first character and
downcase the remaining characters.
Escape,c CapitalizeWord Find the next word starting from the current position and then upcase the first character and
downcase the remaining characters.
Ctrl+c CopyOrCancelLine Either copy selected text to the clipboard, or if no text is selected, cancel editing the lin
e with CancelLine.
Delete DeleteChar Delete the character under the cursor
Ctrl+d DeleteCharOrExit Delete the character under the cursor, or if the line is empty, exit the process.
Alt+l DowncaseWord Find the next word starting from the current position and then make it lower case.
Escape,l DowncaseWord Find the next word starting from the current position and then make it lower case.
Ctrl+k KillLine Move the text from the cursor to the end of the input to the kill ring
Alt+d KillWord Move the text from the cursor to the end of the current or next word to the kill ring
Escape,d KillWord Move the text from the cursor to the end of the current or next word to the kill ring
Alt+r RevertLine Equivalent to undo all edits (clears the line except lines imported from history)
Escape,r RevertLine Equivalent to undo all edits (clears the line except lines imported from history)
Ctrl+t SwapCharacters Swap the current character with the character before it.
Ctrl+_ Undo Undo a previous edit
Ctrl+x,Ctrl+u Undo Undo a previous edit
Ctrl+w UnixWordRubout Move the text from the cursor to the start of the current or previous whitespace delimited wo
rd to the kill ring
Alt+u UpcaseWord Find the next word starting from the current position and then make it upper case.
Escape,u UpcaseWord Find the next word starting from the current position and then make it upper case.
Ctrl+m ValidateAndAcceptLine Accept the input or move to the next line if input is missing a closing token.
If there are other parse errors, unresolved commands, or incorrect parameters, show the error
and continue editing.
Ctrl+y Yank Copy the text from the current kill ring position to the input
Alt+. YankLastArg Copy the text of the last argument to the input
Alt+_ YankLastArg Copy the text of the last argument to the input
Escape,. YankLastArg Copy the text of the last argument to the input
Escape,_ YankLastArg Copy the text of the last argument to the input
Ctrl+Alt+y YankNthArg Copy the text of the first argument to the input
Escape,Ctrl+y YankNthArg Copy the text of the first argument to the input
Alt+y YankPop Replace the previously yanked text with the text from the next kill ring position
Escape,y YankPop Replace the previously yanked text with the text from the next kill ring position
Cursor movement functions
=========================
Key Function Description
--- -------- -----------
LeftArrow BackwardChar Move the cursor back one character
Ctrl+b BackwardChar Move the cursor back one character
Alt+b BackwardWord Move the cursor to the beginning of the current or previous word
Escape,b BackwardWord Move the cursor to the beginning of the current or previous word
Home BeginningOfLine Move the cursor to the beginning of the line
Ctrl+a BeginningOfLine Move the cursor to the beginning of the line
End EndOfLine Move the cursor to the end of the line
Ctrl+e EndOfLine Move the cursor to the end of the line
RightArrow ForwardChar Move the cursor forward one character
Ctrl+f ForwardChar Move the cursor forward one character
Alt+f ForwardWord Move the cursor forward to the end of the current word, or if between words, to the end of the next word.
Escape,f ForwardWord Move the cursor forward to the end of the current word, or if between words, to the end of the next word.
History functions
=================
Key Function Description
--- -------- -----------
Alt+< BeginningOfHistory Move to the first item in the history
Alt+> EndOfHistory Move to the last item (the current input) in the history
Ctrl+s ForwardSearchHistory Search history forward interactively
DownArrow NextHistory Replace the input with the next item in the history
Ctrl+n NextHistory Replace the input with the next item in the history
UpArrow PreviousHistory Replace the input with the previous item in the history
Ctrl+p PreviousHistory Replace the input with the previous item in the history
Ctrl+r ReverseSearchHistory Search history backwards interactively
Completion functions
====================
Key Function Description
--- -------- -----------
Tab Complete Complete the input if there is a single completion, otherwise complete the input with common prefix for al
l completions. Show possible completions if pressed a second time.
Alt+= PossibleCompletions Display the possible completions without changing the input
Prediction functions
====================
Key Function Description
--- -------- -----------
F4 ShowFullPredictionTooltip Show the full tooltip of the selected list-view item in the terminal's alternate screen buffer.
F2 SwitchPredictionView Switch between the inline and list prediction views.
Miscellaneous functions
=======================
Key Function Description
--- -------- -----------
Ctrl+l ClearScreen Clear the screen and redraw the current line at the top of the screen
Alt+0 DigitArgument Start or accumulate a numeric argument to other functions
Alt+1 DigitArgument Start or accumulate a numeric argument to other functions
Alt+2 DigitArgument Start or accumulate a numeric argument to other functions
Alt+3 DigitArgument Start or accumulate a numeric argument to other functions
Alt+4 DigitArgument Start or accumulate a numeric argument to other functions
Alt+5 DigitArgument Start or accumulate a numeric argument to other functions
Alt+6 DigitArgument Start or accumulate a numeric argument to other functions
Alt+7 DigitArgument Start or accumulate a numeric argument to other functions
Alt+8 DigitArgument Start or accumulate a numeric argument to other functions
Alt+9 DigitArgument Start or accumulate a numeric argument to other functions
Alt+- DigitArgument Start or accumulate a numeric argument to other functions
F1 ShowCommandHelp Shows help for the command at the cursor in an alternate screen buffer.
Ctrl+Alt+? ShowKeyBindings Show all key bindings
Alt+h ShowParameterHelp Shows help for the parameter at the cursor.
Ctrl+x,Ctrl+e ViEditVisually Invokes the console compatible editor specified by $env:VISUAL or $env:EDITOR on the current command
line.
Alt+? WhatIsKey Show the key binding for the next chord entered
Selection functions
===================
Key Function Description
--- -------- -----------
Ctrl+x,Ctrl+x ExchangePointAndMark Mark the location of the cursor and move the cursor to the position of the previous mark
Shift+LeftArrow SelectBackwardChar Adjust the current selection to include the previous character
Shift+Home SelectBackwardsLine Adjust the current selection to include from the cursor to the start of the line
Alt+B SelectBackwardWord Adjust the current selection to include the previous word
Alt+a SelectCommandArgument Make visual selection of the command arguments.
Shift+RightArrow SelectForwardChar Adjust the current selection to include the next character
Alt+F SelectForwardWord Adjust the current selection to include the next word using ForwardWord
Shift+End SelectLine Adjust the current selection to include from the cursor to the end of the line
Ctrl+@ SetMark Mark the location of the cursor
Alt+Spacebar SetMark Mark the location of the cursor
Search functions
================
Key Function Description
--- -------- -----------
Ctrl+] CharacterSearch Read a character and move the cursor to the next occurrence of that character
Ctrl+Alt+] CharacterSearchBackward Read a character and move the cursor to the previous occurrence of that character
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