1

In the CMD interpreter on Windows, the Up (↑) 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. What's more, pressing the Down (↓) arrow doesn't return to the previous command, as normal navigatiion through the command history would allow. Instead, you're now back at square one, with a blank line of input. Essentially then, when you're typing in the first command of a new CMD instance, the Up key doubles as a "clear input" key.

Whilst this seems like a relatively minute problem that only applies to the very specific scenario described above, and whether it's actually just an odd idiosyncrasy of CMD or an actual bug, I can't count the amount of times over the last few days I've inadvertently lost long and complicated commands in the midst of trying to learn more advanced CMD, and it'd be nice if there were some workaround/fix for it. Who knows, maybe it's actually a "feature, not a bug", and that it serves some actual design purpose that I've missed. Either way, I'd appreciate some enlightenment.

enter image description here

One accidental press of the Up (↑) key later...

enter image description here

  • 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 '16 at 2:04
  • again not really an answer but there is also f7 you could use for command history. – barlop Nov 23 '16 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 '16 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 '16 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 '16 at 19:18
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.

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.