Skip to content

Feature Request: adopt Linux-style PSReadLine default key bindings (Ctrl+A/Ctrl+E, Tab -> MenuComplete, Up/Down -> prefix history search) #28459

Closed

Description

@soredake

Prerequisites

  • Write a descriptive title.

Description of the new feature/enhancement

As a PowerShell user editing commands interactively,
I want the default PSReadLine key bindings to match the bindings used by Linux/Emacs-style shells (bash, zsh, fish) out of the box,
so that muscle memory transfers across platforms,
common editing tasks take fewer keystrokes,
and new users get an efficient out-of-box editing experience
without having to copy key-binding snippets into every $PROFILE.

This is the same request as #1839, which was closed without a change to the defaults.
I've searched both PowerShell/PowerShell and PowerShell/PSReadLine and haven't found an open duplicate.
(This issue was initially filed at #28459 and is moved here,
since the default bindings live in this repository.)

I am politely asking that the shipped default bindings be changed to the following
(the same snippet many users already carry in their profiles):

Set-PSReadlineKeyHandler -Key Ctrl+a -Function BeginningOfLine
Set-PSReadlineKeyHandler -Key Ctrl+e -Function EndOfLine
Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete
Set-PSReadLineKeyHandler -Key UpArrow -ScriptBlock {
  [Microsoft.PowerShell.PSConsoleReadLine]::HistorySearchBackward()
  [Microsoft.PowerShell.PSConsoleReadLine]::EndOfLine()
}
Set-PSReadLineKeyHandler -Key DownArrow -ScriptBlock {
  [Microsoft.PowerShell.PSConsoleReadLine]::HistorySearchForward()
  [Microsoft.PowerShell.PSConsoleReadLine]::EndOfLine()
}

Current vs. proposed bindings

Key Current default (Windows edit mode) Current default (Emacs edit mode) Proposed
Ctrl+A SelectAll BeginningOfLine BeginningOfLine
Ctrl+E (unbound) EndOfLine EndOfLine
Tab TabCompleteNext (cycles inline) Complete (bash-style) MenuComplete
UpArrow PreviousHistory PreviousHistory HistorySearchBackward + cursor to end of line
DownArrow NextHistory NextHistory HistorySearchForward + cursor to end of line

Home/End remain bound to BeginningOfLine/EndOfLine; this change adds the Ctrl-based bindings, it does not remove Home/End.

Detailed usability improvements vs. the current bindings

1) Ctrl+A → BeginningOfLine, Ctrl+E → EndOfLine

What we gain compared to the current Windows edit mode:

  • It matches readline/Emacs/fish muscle memory. bash and zsh (in their default emacs editing mode) and fish all bind Ctrl+A/Ctrl+E to beginning/end of line. Anyone arriving from those shells — or from Emacs — currently has to re-learn or re-bind these keys on Windows.
  • The Windows edit mode is the outlier today. PSReadLine's own Emacs edit mode already binds Ctrl+A/Ctrl+E exactly this way, so the proposal makes the edit modes consistent instead of making Windows users special-case their muscle memory per edit mode.
  • Ctrl+E is unbound in the Windows edit mode today. There is currently no control-key binding for "jump to end of line" at all. Filling that gap costs nothing and removes a real inconsistency between the two edit modes.
  • Home-row editing. Home and End are grouped with Insert/Delete/PageUp/PageDown on full keyboards and are often only reachable via Fn on compact laptop keyboards. In a REPL you constantly navigate to the end of the command line to append a flag or a path, and back to the start to change the command itself. Ctrl+A/Ctrl+E keep both hands on the home row and are reachable without looking down.
  • SelectAll on Ctrl+A is low-value in a REPL. Selecting the entire single command line and replacing it on the next keystroke is a niche workflow; the common "select the current command" case is still served by Shift+End (SelectLine). Removing the overloaded meaning from Ctrl+A also removes the surprising "press Ctrl+A, type, and wipe the line" gesture.
  • Cross-platform consistency. One hand position across Windows, Linux and macOS, and across edit modes; fewer edit-mode-specific docs to maintain.

2) Tab → MenuComplete

What we gain compared to TabCompleteNext (the Windows default):

  • From guessing-and-cycling to browsing-and-picking. Today, each Tab replaces the text with the next candidate, invisibly. With a few candidates that is tolerable; with dozens or hundreds (file paths, module names, parameter values such as Azure resource names) it degenerates into blind cycling — no overview of the candidate set, no memory of where you are in the list, easy to overshoot the item you wanted, and Shift+Tab gymnastics to backtrack.
  • The full candidate set is shown at a glance. MenuComplete opens an interactive menu of all matches: arrow keys / PageUp / PageDown / Tab move between items, and it doubles as lightweight documentation (e.g. git switch <Tab> shows your branches, a cmdlet parameter shows the allowed values).
  • You can refine the result. Typing more characters while the menu is open filters the matches live, and Backspace widens the filter again — so narrowing from hundreds of matches to a handful takes a couple of keystrokes instead of a full cycle.
  • Escape cancels losslessly. Escape/Ctrl+G backs out of the menu and restores your original input text, so experimenting with completion is risk-free.
  • Zero cost when the answer is unambiguous. With exactly one match, MenuComplete inserts it immediately without opening a menu (verified in CompleteImpl); with no matches it simply does nothing. The only behavior change is when there are multiple matches to choose from — which is exactly when the extra UI pays for itself.
  • It is consistent with the direction PSReadLine is already taking. MenuComplete already exists and is already bound to Ctrl+Space (Windows) / Ctrl+@; this request just makes Tab reach it. The Emacs edit mode keeps its bash-style Complete, which maintainers have indicated is superior for its context — so this could be scoped to the Windows edit mode if preferred.
  • Aligns with maintainer feedback in Enable Gitter #1839. In PSReadLine Enable Gitter #1839, @lzybkr agreed the history/completion defaults deserved reconsideration and was open to changing the Windows default, and @SeeminglyScience sketched the ideal menu experience. The current MenuComplete implements essentially that sketch: single result completes inline, ambiguous results open a navigable menu, typed characters filter, Escape cancels, Tab advances.

Trade-off to call out honestly: this is the most visible of the four changes. Users who have built TabCompleteNext muscle memory for cycling one candidate per press would need an adjustment period and, if they prefer the old behavior, a one-line profile change. It mirrors the (very popular) menu-complete settings in zsh/fish more than stock bash, and it is the change most worth debating — I am not asking to remove TabCompleteNext, only to change which function Tab invokes by default.

3) UpArrow/DownArrow → prefix-based history search, cursor moved to end

What we gain compared to PreviousHistory/NextHistory:

  • Search instead of paging. Today, Up cycles through all history entries regardless of what you have typed. With a long history (which accumulates fast, and PSReadLine includes entries from previous sessions) you may page through dozens of unrelated commands. With the proposed binding, typing git s and pressing Up jumps straight to the most recent git s… command, and repeated presses walk back through only the matching entries. This is the behavior fish ships by default, and the behavior of readline's history-search-backward/history-search-forward, a ubiquitous opt-in in bash/zsh dotfiles.
  • The cursor lands at the end of the line, like bash/fish/Emacs and like git users expect. With the current default (-HistorySearchCursorMovesToEnd defaults to $false), recalling a command with HistorySearchBackward leaves the cursor right after the typed prefix — i.e. inside the recalled line. In practice you almost always want to edit the tail (change a flag, add a path, swap an argument), which today means an extra, unnecessary End keypress after every recall. Wrapping the calls in the ScriptBlock above gives the desired behavior regardless of the user's -HistorySearchCursorMovesToEnd setting. (Alternatively, the same effect could be achieved by binding Up/DownArrow to HistorySearchBackward/HistorySearchForward and changing the default of HistorySearchCursorMovesToEnd to $true — whichever the maintainers prefer.)
  • DownArrow mirrors this, walking forward through matches back toward your in-progress line — something NextHistory cannot express when combined with a prefix.
  • No regression on an empty line. With an empty prefix, HistorySearchBackward matches every entry — i.e. it behaves like PreviousHistory (it merely skips entries from other sessions, which is arguably the desirable behavior here).
  • No regression in multi-line buffers. HistorySearch detects LineIsMultiLine() and moves within the multi-line buffer (MoveToLine) instead of jumping into history — so editing a multi-line command still works as you would expect, the same way zsh's up-line-or-history behaves.
  • Prefix emphasis. PSReadLine already highlights the searched prefix in the buffer during the search, which makes it visually obvious why a given entry was selected.
  • In-progress line is preserved and recoverable. HistorySearchBackward saves the current line before searching, so holding DownArrow until the end brings you back to exactly what you were typing.
  • Net keystroke reduction in the extremely common "re-run the last kubectl/git/ssh command with a tweak" workflow: two keystrokes (type prefix, press Up) instead of N paging presses, with fewer chances of accepting the wrong entry.

Consistency payoff across all four changes

  • One set of conventions across Windows and non-Windows, and across Windows and Emacs edit modes.
  • Fewer "why doesn't PowerShell feel like my shell?" surprises for new users.
  • Profile snippets shrink: less copy-paste boilerplate in every shared profile and onboarding doc.
  • None of the existing functions (SelectAll, TabCompleteNext, PreviousHistory, NextHistory) are removed or renamed — existing user overrides and Set-PSReadLineOption -EditMode workflows keep working unchanged.

Proposed technical implementation details (optional)

  • The defaults live in SetDefaultWindowsBindings / SetDefaultEmacsBindings in KeyBindings.cs;
    the Windows edit mode is the out-of-box default on Windows, Emacs on other platforms.
  • Tab (MenuComplete → CompleteImpl(true)): with exactly one match the completion is inserted inline;
    with no matches nothing happens; with multiple matches an interactive menu is shown
    (arrows / PageUp / PageDown / Tab navigate, typed characters filter via FilterCompletions,
    Backspace widens the filter, Escape/Ctrl+G cancels with undo restoring the original line).
  • Up/DownArrow (HistorySearchBackward/Forward): HistorySearch uses the text before the cursor as the prefix
    (_searchHistoryPrefix), matches history entries by prefix,
    and falls back to MoveToLine for multi-line buffers.
    The proposed ScriptBlock additionally calls EndOfLine() so the cursor lands at the end of the recalled line,
    compensating for DefaultHistorySearchCursorMovesToEnd = false.
    An alternative implementation is to bind Up/DownArrow directly to HistorySearchBackward/HistorySearchForward
    and flip HistorySearchCursorMovesToEnd's default to $true.

Open questions for maintainers (happy to adapt the request):

  1. Scope of Tab → MenuComplete: all edit modes, or only the Windows edit mode (keeping Emacs' bash-style Complete, as suggested in Enable Gitter #1839)?
  2. Scope of Up/DownArrow: all edit modes, or only Windows? (Both edit modes currently use PreviousHistory/NextHistory.)
  3. Implementation of cursor-at-end: script-block bindings as written, or binding Up/DownArrow to HistorySearchBackward/Forward and flipping HistorySearchCursorMovesToEnd's default to $true?
  4. Discoverability/signposting: should this ship with a release-notes entry and updated about_PSReadLine_Functions/about_PSReadLine docs, given it is a visible behavioral change to an out-of-box experience?

Thanks for your time and for maintaining PSReadLine — and for considering this.

Activity

  1. soredake commented on Nov 19, 2026

    @soredake
    Author

    Moved to PowerShell/PSReadLine issue 5240, the repository where the default bindings live.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions