For a year, working on Windows laptops has been nonoptional for me. I've been desperately trying to make my environment as close as it is on Mac OS, with the added challenge to do it without the Windows Subsystem for Linux (WSL). So this relies heavily on Powershell.
One thing I like from the fish shell (and was reproduced in zsh by the zsh-autosuggestion plugin) is the autosuggestion feature.
It's that thing where when you start typing something and there is something that starts with the same letters in your history, it'll write it after the cursor in grayed colors. And it's awesome.
For Powershell, it´s called predictive IntelliSense in PSReadLine.
Prerequisites
- Powershell 5.1 or higher
Installation
-
First, install ´PSReadLine´ version 2.1.0
Install-Module PSReadLine -RequiredVersion 2.1.0
1. Then, initialize it with the command below
```
Import-Module PSReadLine
Set-PSReadLineOption -PredictionSource History
And there it is!
(Optional) Initialize it in your profile
-
Check if you already have a profile
Test-path $profile
1. If false, create one
```
New-item –type file –force $profile
-
If yes, edit it
notepad $profile
1. Run this command and close your terminal
```
Set-ExecutionPolicy RemoteSigned
-
Update your profile file like in step 3, and add those lines to it
Import-Module PSReadLine Set-PSReadLineOption -PredictionSource History
And that's it!
![Autosuggest in Powershell](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m0yg202h1ju1o1cd4aeb.gif)
Top comments (8)
Thanks a lot!
If you get the following error:
installing a prerelease may solve the issue:
I am able to get the autosuggestions but still unable to get ZSH like view like green >, colors, etc. Am I missing something?
The gif seems to be using starship terminal:
starship.rs/
Thanks bro, this useful for me
thanks, very useful.
Thanks alot! I Love it
Thanks, this will help learning powershell in ease
Thank you, Thomas
Now it looks more like fish :)