Using Predictive IntelliSense in PowerShell

PowerADM.com / Windows / Windows 10 / Using Predictive IntelliSense in PowerShell

Predictive IntelliSense is a new feature in PSReadline 2.1 and is available by default in PowerShell 7.2. When typing a command in the PowerShell console, Predictive IntelliSense suggests the appropriate commands you have previously typed (using the history of previous PowerShell commands). Predictive IntelliSense works differently than the TAB auto-completion feature (or Bash’s TAB auto-completion). the suggestion of subsequent characters in the command is displayed in gray text after the cursor.

Predictive IntelliSense in PowerShell prompt

The Predictive IntelliSense feature works fine in the regular PowerShellworks console, Windows Terminal, and Visual Studio Code prompt.

You can enable this feature even in Windows PowerShell 5.1. To do this, install the PSReadLine 2.2.2 (or higher) module from PSGallery:

Install-Module PSReadLine -Force

Predictive IntelliSense is disabled by default. To enable it:

Set-PSReadLineOption -PredictionSource History

By default, suggestions are grayed out. To change the color, run:

Set-PSReadLineOption -Colors @{ InlinePrediction = '#74b4f7'}

To disable Predictive IntelliSense hints:

Set-PSReadlineOption -PredictionSource None

When you type a command, to confirm with the proposed command, you need to press the right arrow key.

To reset the Predictive IntelliSense suggestion, press Escape. This will clear all current suggestions in the console.

Using the F2 key, you can switch between SwitchPredictionView modes. InlineView mode (only one command is displayed) and ListView (all available commands that match your text are displayed in a dropdown list below the line the user is typing) are available.

In ListView mode, you can navigate through the suggested history commands using the UpArrow and DownArrow keys.

PSReadLine ListView History predictions in PowerShell

To completely disable Predictive IntelliSense in the PowerShell console:

Set-PSReadlineOption -PredictionSource None
Leave a Reply

Your email address will not be published. Required fields are marked *