如何部分自动完成?

huangapple go评论46阅读模式
英文:

How to partially autocomplete?

问题

我正在使用 PSReadLine 版本 2.2.6(与 PowerShell 7.3 一起使用),具有以下配置选项:

Set-PSReadLineOption -PredictionSource History
Set-PSReadLineOption -EditMode Windows

假设在我的历史记录中,我先前输入过:

remove-Item -Force -Recurse .\node_modules\

但现在我只想更改 .\node_modules\。当我开始输入 remove 时,PSReadLine 会建议整个行,有没有一种方法可以验证建议命令的某些部分?

更明确地说,我想自动完成,直到(不包括)下图中第2部分,以便更改文件夹的名称:

如何部分自动完成?

在这个例子中,我可以直接到末尾并使用 Ctrl + Backspace,但有时命令参数(如 -Force 和 -Recurse)位于末尾,我想保留它们。

英文:

I'm using PSReadLine version 2.2.6 (with PowerShell 7.3.) with the following configuration options:

Set-PSReadLineOption -PredictionSource History
Set-PSReadLineOption -EditMode Windows

Imagine that in my history, I have previously typed:

remove-Item -Force -Recurse .\node_modules\

But now I just want to change .\node_modules\
When I start to type remove, PSReadLine suggest me the whole line, is there a way to validate some parts of the suggested commands?

To be more clear, I want to autocomplete until (excluded) part 2 of the following picture to be able to change the folder's name:

如何部分自动完成?

In this example I could just go to the end and use Ctrl + Backspace but sometimes the command parameters (like -Force and -Recurse) are located at the end and I want to keep them.

答案1

得分: 1

这里讨论了一些关键绑定选项和一个示例 $profile:https://devblogs.microsoft.com/powershell/announcing-psreadline-2-1-with-predictive-intellisense/

英文:

Some of the keybinding options and a sample $profile are discussed here: https://devblogs.microsoft.com/powershell/announcing-psreadline-2-1-with-predictive-intellisense/

huangapple
  • 本文由 发表于 2023年3月15日 20:36:14
  • 转载请务必保留本文链接:https://go.coder-hub.com/75744794.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定