Windows – Is there any way to prevent the current CMD input being erased by a blank history suggestion

cmd.execommand historycommand linewindows

In the CMD interpreter on Windows, the arrow key replaces the current input (not sure what the accurate term is) with commands in the command history; commands that have previously been executed.

An odd idiosyncrasy of CMD is that on a fresh instance, when there are no previous commands in the history, the accidental pressing of the Up arrow key replaces the current input with the last "command" in the history; nothing, essentially clearing the input:

enter image description here

enter image description here

What's more, pressing the key doesn't return the previous command as you would expect; it's permanently lost. Essentially then, in the command prompt, the Up arrow doubles as a "clear input" key.

Can this be fixed at all?

Best Answer

You could try adding Clink to your environment. It has a feature "History persistence between sessions" and from my testing (I typed a long command, did not execute it, pressed the up key and then the down) it displayed the last used command and the brought back the long command I'd typed.

Related Question