2016-05-02 70 views

回答

1

PowerShell中沒有按」沒有一貫的歷史。你可以(在某種程度上)save/restore命令歷史記錄自己與這樣的:

Get-History | Export-Clixml 'C:\path\to\history.xml' 
Import-Clixml 'C:\path\to\history.xml' | Add-History 

使用Get-History列出的歷史和Invoke-History從歷史調用命令。在保存和恢復可以通過把這樣的事情到你的PowerShell profile自動化:

Register-EngineEvent -SourceIdentifier PowerShell.Exiting -Action { 
    Get-History | Export-Clixml "$env:USERPROFILE\ps_history.xml" 
} | Out-Null 

if (Test-Path -LiteralPath "$env:USERPROFILE\ps_history.xml") { 
    Import-Clixml "$env:USERPROFILE\ps_history.xml" | Add-History 
} 

不過,這不會使「歷史」通過光標鍵可用的命令。如果您希望您需要運行PowerShell,例如Console2ConEmuClink

+0

您還可以使用'#history_id_number'選項卡完成功能。 – PetSerAl

+0

@AnsgarWiechers我接受了答案,但實際上命令歷史**光標鍵**是我正在尋找和當你寫它不可用。它也不能用於Console2。我放棄了你建議的其他遊戲機。 –

相關問題