Dhravya's Blog


og-image
February 26, 20220.74 min read

How to add autocomplete to PowerShell in 2 steps

One of my friends informed me about this really cool feature that allows you to add autocomplete to Windows powershell in 2 easy steps:

Here’s a demo of what we’ll be doing today (Thanks to nexxel for the blog idea)

https://us-east-1.tixte.net/uploads/img.dhravya.dev/M22.gif

How? By using PSReadLine

Step one

Install PSreadline

Install-Module PSReadLine

Step two

Open your PowerShell PROFILE in your preferred editor (get the file by using $PROFILE )

paste this code snippet:

Import-Module PSReadLine

# Shows navigable menu of all options when hitting Tab
Set-PSReadLineKeyHandler -Key Tab -Function MenuComplete

# Autocompleteion for Arrow keys
Set-PSReadLineOption -HistorySearchCursorMovesToEnd
Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward
Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward

Set-PSReadLineOption -ShowToolTips
Set-PSReadLineOption -PredictionSource History

And that’s it!!


Dhravya Shah

Personal blog of Dhravya Shah. I’m a Student who loves to code, share ideas and help others!

You may follow me on twitter or join my newsletter for latest updates.

-