Improving the usability of PowerShell on the command line with PSReadLine

1 min read · Updated 25 April 2022

Did this guide help you? You can support me by subscribing to the channel, sharing it, disabling your ad blocker or making a donation. Thank you!

Hello,

The PSReadLine PowerShell module replaces the command line experience for PowerShell 3 and above. It provides the following:
- Syntax highlighting
- Syntax error notification
- Multiline editing
- Customisation of keyboard shortcuts
- Windows, Emacs or Vi mode
- Completion
- Predictive completion
- History

https://github.com/PowerShell/PSReadLine

Prediction is enabled by default in PSReadLine 2.2.6.

Syntaxes used in the video

# Windows PowerShell installation.
powershell -noprofile -command "Install-Module PSReadLine -Force -SkipPublisherCheck"
# Installation under PowerShell Core/7
pwsh.exe -noprofile -command "Install-Module PSReadLine -Force -SkipPublisherCheck -AllowPrerelease"
# You can create a profile file to customise and configure the module
notepad $profile
## You can add the following information:
# Load the module
Import PSReadLine module
# Navigable menu when using TAB
Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete
# Enable prediction based on history
Set-PSReadLineOption -PredictionSource History
# Configure the prediction view as a list
Set-PSReadLineOption -PredictionViewStyle ListView
# Use Windows editing mode
Set-PSReadLineOption -EditMode Windows
## Save and run PowerShell to test
# Show all keyboard shortcuts
Get-PSReadlineKeyHandler

Video : Improving the usability of PowerShell on the command line with PSReadLine

Play

Related links