使用PowerShellGet安装PSReadLine

1
Install-Module -Name PSReadLine

安装后若提示有PSReadLine 2.2.6版本更新,则进一步安装

配置PSReadLine

  1. 打开 PowerShell,在命令行里输入:

    1
    2
    # vscode
    code $PROFILE
  2. 打开文本编辑器,在 PowerShell 的配置文件中添加以下设置命令:

    1
    2
    # 指定 PSReadLine 预测命令来源
    Set-PSReadlineOption -PredictionSource History
  3. 关闭 PowerShell 并再次打开,输入命令即可观察变化。