PowerShell(7) 配置 PSReadLine 历史记录和提示

795 阅读1分钟

PowerShell(7) 配置 PSReadLine 历史记录和提示

具体参考官方文档 PSReadLine

  1. 安装模块

    1. Install-Module -Name PowerShellGet -Force
      Install-Module PSReadLine
      
    2. Get-InstalledModule # 查看已安装模块
      
  2. 复制下面命令到powershell 终端

    if (!(Test-Path -Path $PROFILE )) { New-Item -Type File -Path $PROFILE -Force }
    code $PROFILE
    

    此时会打开一个配置文件,在配置文件中添加下面这些命令

    Import-Module PSReadLine
    Set-PSReadLineOption -PredictionSource History
    Set-PSReadLineOption -ShowToolTips
    
  3. 重启 PowerShell