powershellpsreadline

How to partially autocomplete?


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:

enter image description here

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.


Solution

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