Add Bash/Linux/Unix-style shortcuts to Command Prompt #14412

Closed
opened 2026-01-31 04:09:34 +00:00 by claunia · 6 comments
Owner

Originally created by @cloudrootab on GitHub (Jul 7, 2021).

Description of the new feature/enhancement

Add support, preferably via an optional toggle, for Bash/Linux/Unix-style console shortcuts. Into the standard windows command prompt. Once you start to incorporate some of them into muscle memory, it becomes obvious that stuff like this is sorely lacking in the ordinary Windows Command Prompt.

Examples of such are (non-exhaustive list)
Ctrl+A = Move text cursor to the beginning of the line.
Ctrl+E = Move text cursor to the end of the line.
Ctrl+B = Move text cursor one step backwards.
Ctrl+U = Cut everything behind the text cursor.
Ctrl+Y = Paste last thing cut in clipboard.
Ctrl+D = Same functionality as the 'Delete'-key

A more exhaustive list can easily be found with simple searches. https://www.howtogeek.com/howto/ubuntu/keyboard-shortcuts-for-bash-command-shell-for-ubuntu-debian-suse-redhat-linux-etc/

Originally created by @cloudrootab on GitHub (Jul 7, 2021). <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 I ACKNOWLEDGE THE FOLLOWING BEFORE PROCEEDING: 1. If I delete this entire template and go my own path, the core team may close my issue without further explanation or engagement. 2. If I list multiple bugs/concerns in this one issue, the core team may close my issue without further explanation or engagement. 3. If I write an issue that has many duplicates, the core team may close my issue without further explanation or engagement (and without necessarily spending time to find the exact duplicate ID number). 4. If I leave the title incomplete when filing the issue, the core team may close my issue without further explanation or engagement. 5. If I file something completely blank in the body, the core team may close my issue without further explanation or engagement. All good? Then proceed! --> # Description of the new feature/enhancement Add support, preferably via an optional toggle, for Bash/Linux/Unix-style console shortcuts. Into the standard windows command prompt. Once you start to incorporate some of them into muscle memory, it becomes obvious that stuff like this is sorely lacking in the ordinary Windows Command Prompt. Examples of such are (non-exhaustive list) Ctrl+A = Move text cursor to the beginning of the line. Ctrl+E = Move text cursor to the end of the line. Ctrl+B = Move text cursor one step backwards. Ctrl+U = Cut everything behind the text cursor. Ctrl+Y = Paste last thing cut in clipboard. Ctrl+D = Same functionality as the 'Delete'-key A more exhaustive list can easily be found with simple searches. https://www.howtogeek.com/howto/ubuntu/keyboard-shortcuts-for-bash-command-shell-for-ubuntu-debian-suse-redhat-linux-etc/ <!-- A clear and concise description of what the problem is that the new feature would solve. Describe why and how a user would use this new functionality (if applicable). -->
claunia added the Issue-FeatureNeeds-TriageNeeds-Tag-FixProduct-Cmd.exe labels 2026-01-31 04:09:34 +00:00
Author
Owner

@zadjii-msft commented on GitHub (Jul 7, 2021):

Man, as much as I'd love that, we won't be updating cmd.exe anytime soon. If you want a modern, updated shell on Windows, you should try out PowerShell 7.

IIRC, PSReadline (a component of pwsh), already includes some of that functionality (though, it may be bound to other keys by default).

@zadjii-msft commented on GitHub (Jul 7, 2021): Man, as much as I'd love that, [we won't be updating `cmd.exe` anytime soon](https://github.com/microsoft/terminal/blob/main/doc/Niksa.md#cmd). If you want a modern, updated shell on Windows, you should try out PowerShell 7. IIRC, PSReadline (a component of pwsh), already includes some of that functionality (though, it may be bound to other keys by default).
Author
Owner

@eryksun commented on GitHub (Jul 7, 2021):

Not that it changes much, but implementing the suggested command-line editing shortcuts would have nothing to do with the CMD shell. It would be new functionality in the cooked read that the console implements for ReadFile and ReadConsole when line-input mode is enabled. This would affect all applications that use the console's cooked read, not just the CMD shell. From what I gather, the console team is not interested in updating the builtin command-line editor with new functionality or configurable behavior such as emacs and vi modes.

@eryksun commented on GitHub (Jul 7, 2021): Not that it changes much, but implementing the suggested command-line editing shortcuts would have nothing to do with the CMD shell. It would be new functionality in the cooked read that the console implements for `ReadFile` and `ReadConsole` when line-input mode is enabled. This would affect all applications that use the console's cooked read, not just the CMD shell. From what I gather, the console team is not interested in updating the builtin command-line editor with new functionality or configurable behavior such as emacs and vi modes.
Author
Owner

@zadjii-msft commented on GitHub (Jul 7, 2021):

You're technically correct, the best kind of correct.

@zadjii-msft commented on GitHub (Jul 7, 2021): You're technically correct, [the best kind of correct](https://www.youtube.com/watch?v=hou0lU8WMgo).
Author
Owner

@DHowett commented on GitHub (Jul 7, 2021):

Yeah -- unfortunately if we add those shortcuts to cooked read (conhost's line editor) it'll immediately take them out of the hands of applications that might want to use them. Even so, maybe that's a non-issue.

I wonder if we should do something here? It's just new bindings for existing things -- in most cases (home, end, delete, backspace, kill-word, etc.) that's just adding another binding for the same thing.

In other cases . . . well, we'd have to design a yank buffer... and decide that we're going "full emacs" 😄

As an aside, I've always appreciated that on macOS, emacs bindings work in all text fields. It took a while to break me of the habit in Windows!

@DHowett commented on GitHub (Jul 7, 2021): Yeah -- unfortunately if we add those shortcuts to cooked read (conhost's line editor) it'll immediately take them out of the hands of applications that might want to use them. Even so, maybe that's a non-issue. I wonder if we _should_ do something here? It's just new bindings for existing things -- in most cases (home, end, delete, backspace, kill-word, etc.) that's just adding another binding for the same thing. In other cases . . . well, we'd have to design a yank buffer... and decide that we're going "full emacs" :smile: _As an aside, I've always appreciated that on macOS, emacs bindings work in all text fields. It took a while to break me of the habit in Windows!_
Author
Owner

@eryksun commented on GitHub (Jul 7, 2021):

I wonder if we should do something here?

I don't disagree with Mike Griese that this shouldn't change for CMD -- especially if we're talking about radically redesigning its input loop to use ReadConsoleInput instead of ReadConsole. I just wanted to highlight that the more direct way, which doesn't touch CMD's source code, would be to extend the console's command-line editor with new edit modes. This would affect all simple command-line shells (e.g. Python's REPL shell and input function just call ReadConsoleW in Windows), which is both a benefit and a curse. I thought that the console team considered the built-in command-line editor in line-input mode to be a mistake, in which case doubling down to extend it with new functionality would be a poor choice. The alternative is to release a C/C++ readline library that's based on low-level ReadConsoleInput, maybe even incorporate it into the Windows API. A readline library can support "Vi", "Emacs", and classic "Windows" modes, like PSReadLine does.

@eryksun commented on GitHub (Jul 7, 2021): > I wonder if we _should_ do something here? I don't disagree with Mike Griese that this shouldn't change for CMD -- especially if we're talking about radically redesigning its input loop to use `ReadConsoleInput` instead of `ReadConsole`. I just wanted to highlight that the more direct way, which doesn't touch CMD's source code, would be to extend the console's command-line editor with new edit modes. This would affect all simple command-line shells (e.g. Python's REPL shell and `input` function just call `ReadConsoleW` in Windows), which is both a benefit and a curse. I thought that the console team considered the built-in command-line editor in line-input mode to be a mistake, in which case doubling down to extend it with new functionality would be a poor choice. The alternative is to release a C/C++ readline library that's based on low-level `ReadConsoleInput`, maybe even incorporate it into the Windows API. A readline library can support "Vi", "Emacs", and classic "Windows" modes, like [PSReadLine does](https://docs.microsoft.com/en-us/powershell/module/psreadline/set-psreadlineoption?view=powershell-7.1).
Author
Owner

@zadjii-msft commented on GitHub (Jul 7, 2021):

The alternative is to release a C/C++ readline library that's based on low-level ReadConsoleInput, maybe even incorporate it into the Windows API. A readline library can support "Vi", "Emacs", and classic "Windows" modes, like PSReadLine does.

I"VE ABSOLUTELY HAD THE SAME THOUGHT.

It wouldn't be total madness to do this. At the end of the day though, someone would need to write the code, and I'm thinking that's sitting way farther down no the backlog for now. But I'd really love to have all these applications that are relying on conhost's cooked read to rely on something that we can update without fear of changing cmd.exe

@zadjii-msft commented on GitHub (Jul 7, 2021): > The alternative is to release a C/C++ readline library that's based on low-level `ReadConsoleInput`, maybe even incorporate it into the Windows API. A readline library can support "Vi", "Emacs", and classic "Windows" modes, like [PSReadLine does](https://docs.microsoft.com/en-us/powershell/module/psreadline/set-psreadlineoption?view=powershell-7.1). I"VE ABSOLUTELY HAD THE SAME THOUGHT. It wouldn't be total madness to do this. At the end of the day though, someone would need to write the code, and I'm thinking that's sitting way farther down no the backlog for now. But I'd really love to have all these applications that are relying on conhost's cooked read to rely on something that we can update without fear of changing cmd.exe
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#14412