iTranslated by AI
PowerShell: Using Completion Features in IntelliSense
tl;dr
- PowerShell's IntelliSense can be extended with plugin modules.
- The
CompletionPredictormodule adds tab completion functionality. - I actually tried using the
CompletionPredictormodule.
Introduction
PowerShell's IntelliSense can be extended with various plugin modules.
The CompletionPredictor module implements PowerShell's completion features into IntelliSense.
An example of running CompletionPredictor is as follows:
C: > cd ~/D
> cd C:\Users\atsushifx\Desktop [Completion]
> cd C:\Users\atsushifx\Documents [Completion]
> cd C:\Users\atsushifx\Downloads [Completion]
As shown above, path candidates are displayed below the command line, and you can select them using the cursor keys. Of course, you can also narrow down the results by typing.
Installing the CompletionPredictor Plugin
The CompletionPredictor module is distributed on the module distribution site PowerShell Gallery. Follow the steps below to install the CompletionPredictor module.
- Run
Install-Moduleon the command line.
> Install-Module -Name CompletionPredictor -Repository PSGallery -force
>
- Add
Import-Moduleto your $profile.
.
.
### Modules
Import-Module -Name CompletionPredictor
- Restart PowerShell.
This completes the installation of the CompletionPredictor module.
Using CompletionPredictor
If CompletionPredictor is installed correctly, completion results will appear in the list of candidates.
For example, candidates with [Completion] displayed on the right, as shown in the following screen, are provided by CompletionPredictor.
C: > cd ~/.
> cd C:\Users\atsushifx\.config [Completion]
> cd C:\Users\atsushifx\.dotnet [Completion]
> cd C:\Users\atsushifx\.local [Completion]
> cd C:\Users\atsushifx\.vscode [Completion]
Additionally, you can switch between ListView and InlineView using the [F2] key.
In InlineView, candidates are displayed sequentially at the cursor position.
Conclusion
As described above, by using the CompletionPredictor module, you can now use completion features.
PowerShell input has become more convenient, such as being able to select paths from a list.
Happy Hacking!
Discussion