1

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?

8
  • great question.. I guess that must've happened to me too.. i never really tried to apply any solution to it though.. this isn't an answer but sometimes it can be worth doing ctrl-c before the up.. or if somebody else is viewing your screen or you want to copy/paste it then :: or rem before the command then enter. You could then only do up when it's blank..(apart from 2nd/3rd... ups) but yeah if you hit up by accident while you have stuff at the command line, you lose that stuff, great point. There are some cmd replacements you might prefer, but I don't know if they resolve that issue.
    – barlop
    Nov 23, 2016 at 2:04
  • again not really an answer but there is also f7 you could use for command history.
    – barlop
    Nov 23, 2016 at 2:06
  • 1
    @barlop <f7> does nothing in a new cmd shell, and also won't store any command until it is executed.
    – DavidPostill
    Nov 23, 2016 at 12:53
  • @DavidPostill I just did F7 on windows 7 cmd.exe , it a)makes a gui pop up with a list of commands and b)doesn't immediately delete what you have typed. So if you hit F7 and may even navigate through with arrow keys, thinking but don't choose anything and just hit escape then you still have what you typed.
    – barlop
    Nov 27, 2016 at 19:16
  • 1
    @barlop OP is referring to a "a fresh instance, when there are no previous commands in the history" (as was my comment to you above)
    – DavidPostill
    Nov 27, 2016 at 19:18

2 Answers 2

1

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.

0

Not much to do with it if we can not alter the functions of the dos console but for my use when I write long lines or complicated things at least, I take notes in some sort of a notepad.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.