I have recently got myself a new Windows 11 laptop, and started exploring powershell. Never used it before on Windows, but I'm a frequest user of zsh
in Mac so not completely new.
I upgraded Powershell to 7.2.1
, but noticed that the auto-suggestion type feature that I'm used to with Oh My Zsh is missing. After searching a bit, I installed PSReadLine
, and setup my profile using the following:
Import-Module PSReadLine
Set-PSReadLineOption -PredictionSource History
Set-PSReadLineOption -HistorySearchCursorMovesToEnd
Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward
Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward
Set-PSReadLineKeyHandler -Key Tab -Function Complete
This is working a lot better than earlier, but I'm noticing that I cannot accept autocompletions partially.
For example, this is part of my history:
New-item –type file –force $profile
If I now try to create a file say test-file
, and start typing New-Item
, I do get the suggestion. I want to accept till the end of -force
, or possibly till file
. That's not happening, whatever be the key combination I try (tried Ctrl+→, Shift+→, Alt+→, Fn+→ in vain).
Of course, I can accept full suggestion and delete what I do not need. While for this example it's reall doesn't matter, but it'll be annoying for long commands with matches present only in initial parts. So, my question is what is the combo to accept suggestions in part, or if that's need to be enabled separately, how do I do it?
From the about_PSReadLine docs
AcceptNextWordSuggestion
Accepts the next word of the inline suggestion from Predictive IntelliSense. This function can be bound with Ctrl+F by running the following command.
Set-PSReadLineKeyHandler -Chord "Ctrl+f" -Function ForwardWord