在 windows 的 powershell 里使用类似 zsh autosuggestion 的命令提示

DebugMi 发布于 2023-03-14编辑于 2023-04-06阅读:11

如图,在 zsh 里,通过 zsh autosuggestion 插件,可以基于历史记录做命令提示,不需要一直输重复的代码,非常爽

Windows 里的 powershell 也可以做到,非常简单

  • 以管理员身份运行 powershell
  • 安装 PSReadLine
Install-Module PSReadLine -RequiredVersion 2.1.0
  • 重启 powershell
  • 初始化
Import-Module PSReadLine
Set-PSReadLineOption -PredictionSource History
  • OK,完成,但重启后还需要再次初始化,所以把它加入配置文件里
notepad $PROFILE
  • 加入一行,保存并关闭
Set-PSReadLineOption -PredictionSource History
  • 下次启动即可拥有 autosuggestion 能力
0