REMOVE THIS REQUEST #22977

Closed
opened 2026-01-31 08:28:59 +00:00 by claunia · 1 comment
Owner

Originally created by @basantrauniyar15 on GitHub (Feb 25, 2025).

Description of the new feature

Description:
While using CMD, we sometimes enter incorrect commands by mistake. However, CMD does not provide a built-in way to remove or undo the last entered command. This can be frustrating, especially when working with Git, file management, or system commands.
For example, if I mistype a command:
cmd
git sttaus (wrong command)

CMD simply returns an error, and I have to manually retype the correct command:
cmd
git status (correct command)

Similarly, if I accidentally create a file or directory:
cmd
mkdir myfolder

I must manually delete it with:
cmd
rmdir /s /q myfolder

Instead of this, a simple undo command could help users immediately remove or correct their last incorrect command.

Proposed technical implementation details

Proposed Implementation:
Command History Handling
CMD can maintain a temporary history of commands.
If the last command resulted in an error (e.g., "not recognized as an internal or external command"), undo would remove it from history.
Undoing Mistaken Commands
If the last command was invalid, undo would simply clear it from history.
If the last command made an unintended change (e.g., mkdir folder), undo could automatically revert the action (rmdir /s /q folder).
Usage Example:
If a user types a wrong command:
cmd
git sttaus (wrong command)

They can run:

cmd
undo

This will remove the incorrect command, so it does not appear when using the up-arrow key in CMD.

If a user accidentally creates a folder:
c
mkdir testfolder

Running:

cmd
undo

Will delete testfolder automatically.

Integration in CMD
The undo command could be built into CMD as an enhancement to history management.
Optionally, undo --last could revert only the last mistake, while undo --list could show recent commands for selection.
This feature would improve workflow efficiency and reduce frustration when working in CMD.

Would love to hear feedback on this idea!

Originally created by @basantrauniyar15 on GitHub (Feb 25, 2025). ### Description of the new feature **Description:** While using CMD, we sometimes enter incorrect commands by mistake. However, CMD does not provide a built-in way to remove or undo the last entered command. This can be frustrating, especially when working with Git, file management, or system commands. For example, if I mistype a command: **cmd git sttaus (wrong command)** CMD simply returns an error, and I have to manually retype the correct command: **cmd git status (correct command)** Similarly, if I accidentally create a file or directory: **cmd mkdir myfolder** I must manually delete it with: **cmd rmdir /s /q myfolder** Instead of this, a simple undo command could help users immediately remove or correct their last incorrect command. ### Proposed technical implementation details Proposed Implementation: Command History Handling CMD can maintain a temporary history of commands. If the last command resulted in an error (e.g., "not recognized as an internal or external command"), undo would remove it from history. Undoing Mistaken Commands If the last command was invalid, undo would simply clear it from history. If the last command made an unintended change (e.g., mkdir folder), undo could automatically revert the action (rmdir /s /q folder). Usage Example: If a user types a wrong command: **cmd git sttaus (wrong command)** They can run: **cmd undo** This will remove the incorrect command, so it does not appear when using the up-arrow key in CMD. If a user accidentally creates a folder: **c mkdir testfolder** Running: **cmd undo** Will delete testfolder automatically. Integration in CMD The undo command could be built into CMD as an enhancement to history management. Optionally, **undo --last** could revert only the last mistake, while **undo --list** could show recent commands for selection. This feature would improve workflow efficiency and reduce frustration when working in CMD. **Would love to hear feedback on this idea!**
claunia added the Issue-FeatureNeeds-TriageNeeds-Tag-FixNeeds-Attention labels 2026-01-31 08:28:59 +00:00
Author
Owner

@DHowett commented on GitHub (Feb 25, 2025):

Hey, that's a fun idea!

My biggest concerns with adding a new CMD built-in are:

  • It will shadow existing commands; if somebody has undo.exe on their path somewhere, CMD's will either win or mislead the user
  • It only works in CMD

The history buffer used by CMD actually works in all sorts of applications, like Python (!). Adding an undo command to CMD won't address the need for it in python, or ruby, or any other application that uses our readline implementation.

However! We actually already have an implementation of this!

If you press F7 to open the History pop-up, you can use Delete to delete commands from your history. You can also move them around by holding Shift and using the arrow keys.

Image

Does that help/?

@DHowett commented on GitHub (Feb 25, 2025): Hey, that's a fun idea! My biggest concerns with adding a new CMD built-in are: - It will shadow existing commands; if somebody has `undo.exe` on their path somewhere, CMD's will either win or mislead the user - It only works in CMD The history buffer used by CMD actually works in all sorts of applications, like Python (!). Adding an `undo` command to CMD won't address the need for it in python, or ruby, or any other application that uses our readline implementation. _However!_ We actually already have an implementation of this! If you press <kbd>F7</kbd> to open the History pop-up, you can use <kbd>Delete</kbd> to delete commands from your history. You can also move them around by holding <kbd>Shift</kbd> and using the arrow keys. ![Image](https://github.com/user-attachments/assets/44064854-cca1-4785-9cd3-d5cd375a66b4) Does that help/?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#22977