

Enable CLI Completion in PowerShell using Bash Completions
source link: https://codyanhorn.tech/blog/enable-cli-completion-in-powershell-using-bash-completions
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

With this article I will go over how I enabled Pulumi Command-Line Completion to PowerShell. Since Pulumi does not have built in completion generation for PowerShell I had to find another way to get this sweet feature. Since Pulumi does support Bash CLI Completion generation we can use this generation to do it!
How It's Done
Here is a high-level overview of what will be needed to get completions running for Pulumi:
Install the PSBashCompletions PowerShell Module
Make sure bash.exe is in our path.
Generate our bash completion script, in our case I am using Pulumi's.
Register our bash completion script with the PSBashCompletions Module.
We rely heavily on the article PSBashCompletions: Bash Argument Completion in PowerShell from Travis Illig, he published the PSBashCompletions PowerShell Module as part of this article. The article states we need to have the bash.exe in our path, this comes along with Git for Windows, so install that if you need too.
Installing BashArgumentCompleter use this command:
Install-Module -Name PSBashCompletions -Scope CurrentUser
To generate the bash completion and output it into a file for Pulumi I used the below PowerShell command:
pulumi gen-completion bash > $PROFILE_PATH/.pulumi_completions
To register our bash completion script with Pulumi:
Register-BashArgumentCompleter pulumi "$PROFILE_PATH/.pulumi_completions"
Testing out the bash completion:
pulumi s<ctrl+space>

Recommend
-
67
-
45
README.md fx-completion Bash completion for fx
-
50
How bash completion works Published October 6, 2019 by Chris Patuzzo This is the first of two parts on Bash completion. Part two ishere. ...
-
16
Auto-update bash completions for kubectl, minikube and helm This bash completion script ensures that you always get the matching bash completions for the installed kubectl, minikube and helm. Simply source it and it will do...
-
6
December 1, 2020 OhMyZsh GitHub CLI Command Completion
-
7
In this post we add shell completions to the XKCD CLI utility we made earlier. We'll show how easy it is to support multiple shells, and generate the completions both at compile time and/or run time. Why Completion Scripts
-
17
Vim bash-completion This repository contains a bash-completion file for vim. The following features are curently supported: auto completion of remote files (vim scp://$host//files) basic argum...
-
4
New issue fix: enable ADT keyword completions in block expressions #11993
-
8
Azure DNS updater using Powershell and Azure CLI Posted on December 6, 2022
-
7
Inside C++/WinRT: Coroutine completions: Avoiding reentrant completion
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK