Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a windows shell tool can keep history? [closed]

Tags:

shell

cmd

history

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.

like image 741
textpattern Avatar asked Feb 13 '12 11:02

textpattern


People also ask

Does PowerShell have history?

PowerShell automatically maintains a history of each session. The number of entries in the session history is determined by the value of the $MaximumHistoryCount preference variable. Beginning in Windows PowerShell 3.0, the default value is 4096 .

Is there a way to see CMD history?

Launch the Command Prompt from the Start menu and type the following the pop-up window: “ doskey /history “ Press “Enter.” The commands you've executed in the active session will appear in the Command Prompt window.

Where is PowerShell ISE history stored?

Its saved under your appdata folder. So use Cat (Get-PSReadlineOption). HistorySavePath to get all historical commands ran.

How do I use PowerShell history?

Using the F8 key, you can find the command in history that matches the text on the current command line. For example, enter get- and press F8 . The last entry in the command history matching this text will be found. To go to the next command in history, press F8 again.


1 Answers

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:

Register-EngineEvent PowerShell.Exiting {
    Get-History -Count 32767 | Group CommandLine | 
    Foreach {$_.Group[0]} | Export-CliXml "$home\pshist.xml" } -SupportEvent

Then to restore upon load all you need is:

Import-CliXml "$home\pshist.xml" | Add-History
like image 191
Michael Kelley Avatar answered Oct 13 '22 06:10

Michael Kelley