Register-AutocompleteCommand
is a PowerShell module designed to simplify and enhance the user experience by enabling auto-completion of command options. It dynamically parses available options and arguments from command-line tools, improving efficiency and usability for PowerShell users.
- PowerShell Version: Compatible with PowerShell 5.1 and later.
- Platform: Works on Windows, macOS, and Linux environments where PowerShell Core or Windows PowerShell is available.
You can install the module directly from the PowerShell Gallery:
Install-Module -Name Register-AutocompleteCommand -Scope CurrentUser -Force
Alternatively, download the script and import it manually:
Import-Module ./Register-AutocompleteCommand.psm1
The module provides a single primary function: Register-AutocompleteCommand
. This function enables autocompletion for specified commands.
Register-AutocompleteCommand -Commands <string[]>
-Commands
(Required): A string array of command names for which autocompletion should be registered. These commands must exist in your system's PATH.
To enable autocompletion for the git
command:
Register-AutocompleteCommand -Commands 'git'
You can specify multiple commands for autocompletion:
Register-AutocompleteCommand -Commands 'git', 'docker', 'kubectl'
To make the autocomplete settings persistent across sessions, add the following to your PowerShell profile:
Import-Module Register-AutocompleteCommand
Register-AutocompleteCommand -Commands 'git', 'docker', 'kubectl'
This will ensure that autocompletion is always enabled for the specified commands.
- Command Help Parsing: The module uses the
help
output of the specified commands to identify their available options and arguments. Common help flags like--help
,-h
, or/help
are automatically attempted. - Dynamic Suggestions: The options are dynamically generated and filtered based on the user’s input as they type.
- Interactive Description: The autocompletion provides not just the option names but also descriptions parsed from the command's help output.
- Commands must support standard help options such as
--help
or-h
. - Some commands with non-standard help formats may not work as expected.
- Requires the commands to be present in the system’s PATH.
This project is licensed under the Licença CC BY-NC-SA 4.0. See the LICENSE file for details.