pwsh7配置自动补全

@pwsh7配置自动补全

pwsh7安装PSReadLine智能补全插件


开启powershell远程执行权限

# 开启powershell远程执行权限
Set-ExecutionPolicy RemoteSigned

# 同意更改 输入Y

检测是否有配置好文件

# 检测是否有配置好文件
Test-path $profile

在这里插入图片描述


如果为false手动创建profile

# 手动创建profile
New-item –type file –force $profile

# 使用记事本打开profile文件
notepad $profile

将下面的内容粘贴到profile中;

# 点击 Tab 时显示所有选项的可导航菜单
Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete

# 箭头键的自动完成
## 设置向上键为后向搜索历史记录
Set-PSReadlineKeyHandler -Key UpArrow -Function HistorySearchBackward
## 设置向下键为前向搜索历史纪录
Set-PSReadlineKeyHandler -Key DownArrow -Function HistorySearchForward

# 自动建议
Import-Module PSReadLine
Set-PSReadLineOption -PredictionSource History

安装PSReadLine自动补全

参考: https://www.cnblogs.com/world-explorer/p/16500936.html
https://www.cnblogs.com/whiter001/p/15226132.html

# 安装依赖
Install-Module -Name GuiCompletion

# 注册TAB按键
Install-GuiCompletion -Key Tab

# 安装PSReadLine
Install-Module PSReadLine -Force

初始化PSReadLine

# 初始化
Set-PSReadLineOption -PredictionSource History

重开pwsh7,使用自动补全

在这里插入图片描述