How Hard Could Installing Autocomplete For PowerShell Be?

Kevin Lin
3 min readNov 1, 2022

--

So, at my last internship, I was introduced to fish-like autosuggestions for zsh.

Basically it shows you a suggestions when you type into your shell, and it gets those suggestions from your shell history. This is incredibly helpful for long commands (e.g. Docker) but useful even just for everyday usage.

So, today, Halloween 2022, I decided it was time I look for something similar on Windows, which lead to a chain of problems and solutions that got so ridiculous that I had to write about it. Follow along to see if you get the same errors.

Table of contents:

  1. The OG Tutorial
  2. Fix by Installing Pre-release PSReadLine
  3. Fix by Updating PowerShellGet
  4. Fix by Force Installing PowerShellGet using Install-Module

1. The OG Tutorial

First, I found this tutorial: https://dev.to/animo/fish-like-autosuggestion-in-powershell-21ec

It says that I need PowerShell version > 5.1, which I have.

Then, it says to just run (in an Administrative PowerShell)

Install-Module PSReadLine -RequiredVersion 2.1.0Import-Module PSReadLineSet-PSReadLineOption -PredictionSource History

Easy, right? Wrong.

I get the error:

Set-PSReadLineOption : A parameter cannot be found that matches parameter name ‘PredictionSource’....

2. Fix by Installing Pre-release PSReadLine

I look up the error and find this Github issues thread: https://github.com/PowerShell/PSReadLine/issues/2189

The top suggestion here says to just run

Install-Module -Name PSReadLine -AllowPrerelease -Scope CurrentUser -Force -SkipPublisherCheck

I try this and get a new error message:

Install-Module : A parameter cannot be found that matches parameter name ‘AllowPrerelease’....

3. Fix by Updating PowerShellGet

Okay. That’s frustrating. So I look up that error message and find this:

https://www.easy365manager.com/install-module-a-parameter-cannot-be-found-that-matches-parameter-name-allowprerelease/

This suggests to run

Update-Module PowerShellGet -Force

Of course, this gives me a new error:

Update-Module : Module ‘PowerShellGet’ was not installed by using Install-Module, so it cannot be updated.
...

4. Fix by Force Installing PowerShellGet using Install-Module

Searching for that error leads me to this article: https://evotec.xyz/update-module-module-powershellget-was-not-installed-by-using-install-module-so-it-cannot-be-updated/

Which says to install PowerShellGet with a -Force option:

Install-Module PowerShellGet -Force

and… no errors!

From there, I restarted PowerShell and ran everything up this stupid linked list of errors:

Update-Module PowerShellGet -ForceInstall-Module -Name PSReadLine -AllowPrerelease -Scope CurrentUser -Force -SkipPublisherCheckSet-PSReadLineOption -PredictionSource History

…and it worked! I had gone through the hero’s journey, being able to use everything that I had learned along the way to get me where I wanted:

Now what was I working on again?

--

--

Kevin Lin
Kevin Lin

Written by Kevin Lin

Engineering Physicist and occasional content creator

No responses yet