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