Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Undo Command for CMD to Remove Previous Mistaken Command #18626

Open
basantrauniyar15 opened this issue Feb 25, 2025 · 2 comments
Labels
Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Needs-Attention The core contributors need to come back around and look at this ASAP. Needs-Tag-Fix Doesn't match tag requirements Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting

Comments

@basantrauniyar15
Copy link

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!

@basantrauniyar15 basantrauniyar15 added the Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. label Feb 25, 2025
@microsoft-github-policy-service microsoft-github-policy-service bot added Needs-Tag-Fix Doesn't match tag requirements Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels Feb 25, 2025
@DHowett
Copy link
Member

DHowett commented 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/?

@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Feb 25, 2025
@basantrauniyar15
Copy link
Author

basantrauniyar15 commented Feb 27, 2025

Subject: Re: Feature Request – Undo Command in CMD

Hi DHowett,

Thanks for your detailed response! I understand the concern about shadowing existing commands and how the history buffer works across different applications. The F7 + Delete method helps in removing the command from history, but it doesn't clear the error message from the CMD screen.

My request is for a command like undo-last, which would:

  • **Remove the last incorrect command and its output from the screen
  • Not affect the rest of the session’s history
  • Work inside CMD without affecting other applications like Python
  • This would be helpful when mistyping commands (e.g., cd list instead of cd folder). Instead of seeing the error, users could undo and retype it cleanly.**
    Would this be possible as a future feature? Looking forward to your thoughts!

Best regards,
Basant Rauniyar

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs-Attention The core contributors need to come back around and look at this ASAP. and removed Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something labels Feb 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Needs-Attention The core contributors need to come back around and look at this ASAP. Needs-Tag-Fix Doesn't match tag requirements Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting
Projects
None yet
Development

No branches or pull requests

2 participants