One of the nice things of Linux is the command history – it stores typically the last 1000 commands or so and its saved every time you log out.
DOS does have this through the
doskey /history command and you can relatively easily append this to a file:
doskey /history >> %USERPROFILE%\history.txt%
The tricky bit is having this done for you on log out.
This only works for the current session though so you need to create a shortcut that runs the command each time with the following Target:
(my apologies if this is missing backslashes, WordPress keeps deleting them!)
%windir%\system32\cmd.exe /K doskey exit=doskey/history$g$g%USERPROFILE%\history.log$texit $1 $2
Then you just have to remember to type
exit each time…
I also found three useful commands – but they’re only for your current session. Hat tip to Nifty Computer Tricks:
- get last command
- current list (use left/right arrow keys to paste to the command line)
- auto-complete (type the first few letters)
Update 2 – Some extra love for the DOS prompt…
If you’ve got this working then I’ve added some extra basics. First you need to install Gow (and I suggest you do it using the Chocolatey package).
Then download my bang.bat / history.bat gist, extract it completely and put the
history.bat into the Gow bin directory e.g.
C:\Program Files (x86)\Gow\bin. These assume you are saving the history to
Then you’ll be able to do commands like
history | grep mysql to list all your mysql commands in
history.log with their line numbers. Then call
bang 123 to execute the specific line of the