环境
Windows Terminal + Power Shell
默认情况下,Power Shell 这个命令是获取当前session下的历史命令,与linux下的history行为不一样,但是可以通过API获取到想要的东西。
PS C:\Users\Administrator> Get-Content (Get-PSReadlineOption).HistorySavePath
可以配合管道进行 处理,如进行搜索 ssh 相关的历史命令:
PS C:\Users\Administrator> Get-Content (Get-PSReadlineOption).HistorySavePath | grep ssh
最好是简写:
参考
官方文档:
- Get-PSReadlineOption: https://docs.microsoft.com/en-us/powershell/module/psreadline/get-psreadlineoption?view=powershell-7.2
- Alias: https://docs.microsoft.com/zh-cn/powershell/module/microsoft.powershell.core/about/about_aliases?view=powershell-7.2
- Get-Content: https://docs.microsoft.com/zh-cn/powershell/module/microsoft.powershell.management/get-content?view=powershell-7.2