Feature Request: Undo Command for CMD to Remove Previous Mistaken Command #18626
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
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!
The text was updated successfully, but these errors were encountered: