如何在重新启动后使用(Windows Powershell)GitShell命令历史记录?

问题描述:

我正在使用Gitshell(Powershell)for windows(7)从官方Github网站下载。如何在重新启动后使用命令历史?如何在重新启动后使用(Windows Powershell)GitShell命令历史记录?

  • 命令exit代替x是无效的(如sugested here

  • 不能看到任何~/.bash_profile~/.bash_history文件(使它像here

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。我放弃了你建议的其他游戏机。 –