美文网首页
powershell配置(2)-psreadline历史记录和智

powershell配置(2)-psreadline历史记录和智

作者: 洗洗睡吧i | 来源:发表于2020-06-11 23:32 被阅读0次

1. 安装 psreadline

ref: https://github.com/PowerShell/PSReadLine

从 PowerShellGallery 中安装。
依次安装PowerShellGet, PSReadLine

Install-Module -Name PowerShellGet -Force
Install-Module PSReadLine
  • 查看已安装的模块 Get-InstalledModule

安装完就有历史纪录了,关闭后可以保存历史记录。

2. 智能提示

安装完之后没有智能提示,按tab键跳出来的命令都很奇怪。(我安的是稳定版,V2.0.2)

发现测试版就加入了类似 fish 的智能提示,版本是V2.1.0-beta2。

ref: https://github.com/PowerShell/PSReadLine/pull/1496

更新一下PSReadLine,然后将 PredictionSourceSource 设为 History

Update-Module PSReadLine -AllowPrerelease
Set-PSReadLineOption -PredictionSource History  # 默认是 None
  • 查看所有设置选项 Get-PSReadLineOption

但是似乎窗口关闭后,就不记得了。
要把设置这一行加到配置文件里就好了,运行code $PROFILE就能打开配置文件。

Done!

相关文章

网友评论

      本文标题:powershell配置(2)-psreadline历史记录和智

      本文链接:https://www.haomeiwen.com/subject/kwlwtktx.html