PowerShell 输入命令时,联想历史记录

@zgcwkj  2025年08月10日

分类:

代码 其它 

PowerShell 输入命令时联想历史记录,启用 PSReadLine 模块的预测性补全

配置 PowerShell 模块仓库的信任策略

Set-PSRepository -Name PSGallery -InstallationPolicy Trusted

取消 PowerShell 模块仓库的信任策略

Set-PSRepository -Name PSGallery -InstallationPolicy Untrusted

查看安装的 PSReadLine 版本

Get-Module -Name PSReadLine -ListAvailable

安装 PSReadLine

Install-Module -Name PSReadLine -Force -AllowClobber

卸载 PSReadLine

Uninstall-Module -Name PSReadLine -Force

卸载 PSReadLine,占用问题,可以用 cmd 卸载

powershell Uninstall-Module -Name PSReadLine -Force

启用预测性补全(基于历史记录)

Set-PSReadLineOption -PredictionSource History

设置预测补全显示方式(InlineView 为行内显示)

Set-PSReadLineOption -PredictionViewStyle InlineView

关闭所有 PowerShell 窗口后,执行以下命令删除历史文件

Remove-Item (Get-PSReadLineOption).HistorySavePath -Force


评论已关闭

Top