如何在重新启动后使用(Windows Powershell)GitShell命令历史记录?
问题描述:
我正在使用Gitshell(Powershell)for windows(7)从官方Github网站下载。如何在重新启动后使用命令历史?如何在重新启动后使用(Windows Powershell)GitShell命令历史记录?
答
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,例如Console2,ConEmu或Clink。
您还可以使用'#history_id_number'选项卡完成功能。 – PetSerAl
@AnsgarWiechers我接受了答案,但实际上命令历史**光标键**是我正在寻找和当你写它不可用。它也不能用于Console2。我放弃了你建议的其他游戏机。 –