I use windows 7 64bit. I found both cmd.exe and powershell cannot keep history. It means it lost my command history when I quit the shell.
Is there a tools can help cmd.exe or powershell to remember the history? I try to use console 2. Console 2 is tiny and has a tab interface. But console 2 can't remember the history too. Maybe there is another front end can do this.
There's an excellent post on the Windows PowerShell Blog that provides a way of preserving command history across sessions:
http://blogs.msdn.com/b/powershell/archive/2006/07/01/perserving-command-history-across-sessions.aspx
The pertinent commands for exporting and importing the command history are
Get-History
andAdd-History
. Add the following to your PowerShell profile:This will preserve the history in such a way that you can still inspect the history for start and end times, and calculate the duration of each.
A warning though: The above script will only remember the history of the most recently exited PowerShell window. If you work with multiple shell sessions at the same time, then the history of all but one of them will be lost.
The answer below is from Keith Hill (PowerShell Microsoft MVP) in his answer to the question powershell history: how do you prevent duplicate commands:
BTW if you want to automatically save this on exit you can do this on 2.0 like so:
Then to restore upon load all you need is: