Fish-like Autosuggestion in Powershell

animo

Thomas Alcala Schneider

Posted on March 26, 2021

Fish-like Autosuggestion in Powershell

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

  1. 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


Enter fullscreen mode Exit fullscreen mode

And there it is!

(Optional) Initialize it in your profile

  1. Check if you already have a profile

    
    
    Test-path $profile
    
1. If false, create one
    ```


    New-item –type file –force $profile


Enter fullscreen mode Exit fullscreen mode
  1. If yes, edit it

    
    
    notepad $profile
    
1. Run this command and close your terminal
    ```


    Set-ExecutionPolicy RemoteSigned


Enter fullscreen mode Exit fullscreen mode
  1. 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)
Enter fullscreen mode Exit fullscreen mode
💖 💪 🙅 🚩
animo
Thomas Alcala Schneider

Posted on March 26, 2021

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

Fish-like Autosuggestion in Powershell
powershell Fish-like Autosuggestion in Powershell

March 26, 2021