Description
Reference issue: RFC#687
Predictive IntelliSense is an addition to the interactive experience to assist in command discovery
and accelerate full command execution. This enables new and experienced users of PowerShell to
discover, edit, and execute full commands based on matching predictions from the users history or
additional provider.
Tab Completion has accelerated the success of both new and experienced PowerShell users. New users get the benefit of discovery; seeing available cmdlets and parameters as options while interactively typing. Experienced users receive the benefit of acceleration; typing less while using the key to quickly complete a command.
The increasing amount of technology translates to an increase in cmdlets and full command
complexity. Predictive IntelliSense is an addition to the concept of Tab Completion; helping the
user discover, build and edit full commands based on the users history or additional plugins.
The proposal is to add Predictive IntelliSense and enhancements for MenuComplete/Dynamic Help to the users interactive experience.
Predictive IntelliSense Protoype maybe found on PSGallery.
Proposed technical implementation details
- Predictive IntelliSense displays a best match command completion from command history. The
prediction may change if a better match is found as the user types additional information. The
predicted command may be accepted, edited, or ignored. It may be possible to support additional
predictive providers.
- Predictions are searchable and may be edited. Additional key bindings may be added to the users
Profile as in the example below:
Set-PSReadLineKeyHandler -Key "Ctrl+d" -Function MenuComplete
Set-PSReadLineKeyHandler -Key "Ctrl+f" -Function ForwardWord
Set-PSReadLineKeyHandler -Key "Ctrl+b" -Function BackwardWord
Set-PSReadLineKeyHandler -Key "Ctrl+z" -Function Undo
Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward
Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward
- Predictions are searchable based on the current cursor position.
- Searching history from cmdlet verb.
- Searching histroy from cmdlet noun.
- Searching history from parameter.
- Predictions may be edited by stepping-through the parameters and arguments.
- Moving forward and backward using additional key bindings.
- Note: Changing the parameter/argument, changes the prediction.
- MenuComplete/Dynamic Help is a current feature of PSReadLine. When combined with Predictive IntelliSense, MenuComplete provides additonal discovery and help information.
- MenuComplete providing cmdlet discovery and help.
- MenuComplete providing parameter discovery and help.
Open discussion items:
- Should the number of lines displayed for MenuComplete be restricted and what should that
restriction be? - Should an interactive cursor-based scroll bar for paging be included?
- What should the content of Dynamic Help include?
- Full cmdlet help is accessible using a key binding to access the help in a virtual terminal. An
additional key binding will return the user from the virtual terminal to the previous screen.
- Predictive IntelliSense Accessibility is managed through the users profile.
Set-PSReadLineOption -Colors @{ Prediction = '#8A0303'}
Set-PSReadLineOption -Colors @{ Prediction = '#2F7004'}
Multiple color code values are supported currently in PSReadLine.
Examples of different color code values:
Set-PSReadLineOption -Colors @{ Prediction = 'DarkRed'}
# Use a ConsoleColor enum
Set-PSReadLineOption -Colors @{ Prediction = [ConsoleColor]::DarkRed}
# 24 bit color escape sequence
Set-PSReadLineOption -Colors @{ Prediction = "$([char]0x1b)[38;5;100m"}
# RGB value
Set-PSReadLineOption -Colors @{ Prediction = "#8181f7"}
- Predictive IntelliSense Extensibility
It may be possible to support 1st party and 3rd party predictive plugins.