45

I've recently upgraded PowerShell to version 7.3.0 version and now, when I type a command, I see its suggestions like when I'm typing pip it adds list like in this image. Or when I type start of the command it suggests its full name.

The problem is that when I press Tab it doesn't complete the command, instead it just starts listing current directories, i.e. here is an image after pressing Tab once. Also even when I start typing the full name of the command like pip li it still shows the ending, but when pressing Tab it just does nothing.

I expected this to complete the current command with the suggestion after Tab is pressed.

I've tried to google this problem but haven't found the exact same case I have with 7.3.0 version.

Sled
  • 18,541
  • 27
  • 119
  • 168
Slakter
  • 553
  • 4
  • 7
  • 3
    The command predictions are separate from tab completion. See https://learn.microsoft.com/en-us/powershell/scripting/learn/shell/using-predictors?view=powershell-7.2 – jkiiski Nov 16 '22 at 08:04
  • 1
    Check out this answer, https://stackoverflow.com/a/74897570/5354229 – NirmalCode Dec 23 '22 at 08:24

1 Answers1

81

Just press -> (right arrow) key

If you want to change key bindings: source: https://devblogs.microsoft.com/powershell/announcing-psreadline-2-1-with-predictive-intellisense/

Key Bindings for Predictions

Key bindings control cursor movement and additional features within the prediction. To support users running Predictive IntelliSense on multiple platforms, key bindings are user-settable from the command line or your profile script.

PSReadLine contains functions to navigate and accept predictions. As an example, to accept a displayed prediction, PSReadLine contains functions:

  • AcceptSuggestion – Accept the current inline suggestion
  • AcceptNextSuggestionWord – Accept the next word of the inline suggestion

AcceptSuggestion is built within ForwardChar, which by default is bound to RightArrow. Pressing RightArrow accepts an inline suggestion when the cursor is at the end of the current line.

AcceptNextSuggestionWord is built within the function ForwardWord, which can be bound with Ctrl+f by Set-PSReadLineKeyHandler -Chord "Ctrl+f" -Function ForwardWord. Pressing Ctrl+f accepts the next word of an inline suggestion when the cursor is at the end of current editing line.

As a user, you can bound other keys to AcceptSuggestion and AcceptNextSuggestionWord for similar functionalities. Search for ForwardCharAndAcceptNextSuggestionWord in SamplePSReadLineProfile.ps1 for an example to make RightArrow accept the next word from inline suggestion, instead of the whole suggestion line.

List of additional suggested key bindings defined in PSReadLine SamplePSReadLineProfile.ps1

Sled
  • 18,541
  • 27
  • 119
  • 168
Burak Demircan
  • 826
  • 7
  • 7
  • 10
    Thank you! Omg that was so simple, though not easy to find without knowing the name of the feature – Slakter Nov 17 '22 at 11:14
  • 6
    Is it possible to change it to tab? – T. de Jong Nov 17 '22 at 14:40
  • 4
    Before finding this StackOverflow question, I was wondering the same and made my little investigation. So I want to share my investigation process https://mnaoumov.wordpress.com/2022/11/21/powershell-predictive-intellisense/ – mnaoumov Nov 21 '22 at 20:13