FIsh-like Autosuggestion in Poweshell
Table of Contents
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
- 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
- If false, create one
New-item –type file –force $profile
- If yes, edit it
notepad $profile
- 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!