Improving the PowerShell editing experience can greatly improve your productivity. PSReadLine, in a line, is a PowerShell module that does just that – it provides improved syntax coloring, better multi-line editing, autocomplete, etc.
PowerShell ships with PSReadLine, but run the following command to install the latest version:
Install-Module -Name PSReadLine -AllowClobber -Force
PSReadLine can be configured using a profile. A PowerShell profile is a PowerShell script file that’s executed when a PowerShell starts.
Create (or open) your profile
I recommend Visual Studio Code for almost all text editing, but any text editor (including notepad) would do:
Update your profile
Add the following lines to your profile:
Set-PSReadlineKeyHandler -Key UpArrow -Function HistorySearchBackward Set-PSReadlineKeyHandler -Key DownArrow -Function HistorySearchForward Set-PSReadLineOption -PredictionSource HistoryAndPlugin # enable predictions Set-PSReadLineOption -HistoryNoDuplicates # prevent duplicates Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete # provide a menu of completions when tab key is pressed
That’s it. Now, relaunch your profile to enjoy a much better PowerShell experience: