windowspowershellpowershell-7.3

How to change the Suggestion completion key on Powershell 7.3.0?


Recently I updated my PowerShell to version 7.3.0 and when typing it shows suggestions. But when I press the Tab key it doesn't autocomplete the suggestion. How to set the Tab as the autocompletion key?


Solution

  • So after doing some research I found out,

    Source: Using predictors in PSReadLine

    So here's how to change key bindings

    Set Tab key as the keybinding for auto complete (AcceptSuggestion)

    Set-PSReadLineKeyHandler -Chord "Tab" -Function AcceptSuggestion
    

    Set RightArrow key as the keybinding for accepting the next word in the suggestion (ForwardWord)

    Set-PSReadLineKeyHandler -Chord "RightArrow" -Function ForwardWord
    

    Note :

    You need to run these each time you open a new session. To avoid that add these to profile.ps1 file. More on Profiles

    OR

    If the file doesn't exist, create a new one.

    Add these lines and save.

    Set-PSReadLineKeyHandler -Chord "Tab" -Function AcceptSuggestion
    Set-PSReadLineKeyHandler -Chord "RightArrow" -Function ForwardWord