Search code examples
powershellintellisenseinteractivepsreadlinepowershell-7

How to disable suggestion while typing in powershell


While executing commands in PowerShell it's automatically suggesting texts

enter image description here

How can I disable these suggestions and also in future if I want to enable the suggestions how can I do it?


Solution

  • Use the Set-PSReadLineOption cmdlet:

    To disable all suggestions:

    Set-PSReadLineOption -PredictionSource None
    

    Enabling offers several options, depending on what source(s) should be used for completions: History, Plugin, or HistoryAndPlugin (the default).

    See this blog post for details.


    Note:

    • Perhaps surprisingly, the cmdlets that configure the behavior of the PSReadLine module, such as Set-PSReadLineOption, do not do so persistently - they only affect the session at hand.

    • Therefore, in order to make (what are effectively) persistent configuration changes, place the command above in your $PROFILE file.

      • Note: Said file does not exist by default; to create it (and its parent directory) on demand, use the following command:

        if (-not (Test-Path $PROFILE)) { $null = New-Item -Force $PROFILE }
        
      • Once you've ensured its existence, to open it for editing it in your system's default text editor, so you can add the desired command(s), call:

        Invoke-Item $PROFILE
        
      • Changes to your $PROFILE file take effect in future sessions (except in those sessions explicitly started without profiles, using the CLI's -NoProfile switch).