This PowerShell module enables lazy loading of argument completion scripts for native commands.
It leverages the new 'fall-back' completer for native commands -- Register-ArgumentCompleter -NativeFallback (introduced in PowerShell v7.6).
When tab completion is triggered for a native command, it checks for a corresponding completion script, loads and registers it on-demand, and then provides completions. It minimizes startup overhead and only loads completion logic as needed.
The module exposes two functions to help you manage completion scripts for native commands:
Adds or updates a completion script for a native command.
The script will be stored in ~/.pwsh/completions/ with the naming convention __<command>.ps1.
Syntax:
Add-CompletionScript -Command <string> -InputScript <string>-Command: The name of the native command (e.g.,docker,kubectl,gh)-InputScript: The completion script content (accepts pipeline input)
Examples:
Add a completion script generated by a native tool:
docker completion powershell | Add-CompletionScript -Command docker
kubectl.exe completion powershell | Add-CompletionScript -Command docker
gh completion -s powershell | Add-CompletionScript -Command ghLists completion scripts that have been added to the module's completion directory.
Syntax:
Get-CompletionScript [[-Command] <string[]>]-Command: Optional. One or more command names to filter by. If omitted, lists all completion scripts.
Examples:
List all completion scripts:
Get-CompletionScriptGet completion script(s) for specific command(s):
Get-CompletionScript docker
Get-CompletionScript docker, kubectl, ghView the content of a completion script:
Get-CompletionScript kubectl | Get-Content- The
PSResourceGetmodule is installed. - A
SecretVaultis created calleddefault.
Create a Personal Access Token (Classic) with package:read permission.
At the time of writing, this is the only type of token that allows these premissions.
## The command should prompt for the secret.
Set-Secret -Name GitHubPackageReadRegister the Repository.
This assumes you called you vault default as described in the prerequisites.
Register-PSResourceRepository `
-name daxian-dbw `
-uri https://nuget.pkg.github.com/daxian-dbw/index.json `
-ApiVersion V3 `
-CredentialInfo @{ VaultName='default'; SecretName='GitHubPackageRead' } `
-TrustedThen, you can install the module:
Install-PSResource -Name PSNativeToolCompletion -Repository daxian-dbw