最近,我将 PowerShell 更新到了 7.3.0 版本,并且在输入时会显示建议。但是当我按 Tab 键时,它不会自动完成建议。如何设置Tab
作为自动完成键?
所以在做了一些研究之后我发现,
- 默认自动完成键是
RightArrow
key.
- 您可以逐字接受建议
- 您可以更改建议视图类型
InlineView
and ListView
通过按F2
Source: 在 PSReadLine 中使用预测器 https://learn.microsoft.com/en-us/powershell/scripting/learn/shell/using-predictors?view=powershell-7.3
这是更改键绑定的方法
Set Tab
键作为自动完成的键绑定(AcceptSuggestion)
Set-PSReadLineKeyHandler -Chord "Tab" -Function AcceptSuggestion
Set RightArrow
key 作为接受建议中下一个单词的键绑定 (ForwardWord)
Set-PSReadLineKeyHandler -Chord "RightArrow" -Function ForwardWord
Note :
每次打开新会话时都需要运行这些。为了避免这种情况,将这些添加到profile.ps1
file. 更多关于个人资料的信息 https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_profiles?view=powershell-7.3
OR
如果该文件不存在,请创建一个新文件。
添加这些行并保存。
Set-PSReadLineKeyHandler -Chord "Tab" -Function AcceptSuggestion
Set-PSReadLineKeyHandler -Chord "RightArrow" -Function ForwardWord
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)