complete command that provides context-sensitive tab completion for your shell. It enables completion of command names, argument names, and argument values based on the current command line state.
This feature was released in v0.1.42241 Preview. Update to this version or later to use completion.
How Tab Completion Works
Tab completion cycles through possible values as you press the Tab key repeatedly. Here’s what you can complete:- Command names - Complete main commands like
install,search,show - Argument names - Complete flags and options like
--version,--source - Argument values - Complete package names, versions, and other contextual values
Completion Examples
These examples assume tab completion works similar to PowerShell, where repeated Tab presses cycle through possible values.| Input | Result | Reason |
|---|---|---|
winget ⇥ | winget install | install is the first command below the root |
winget sh⇥ | winget show | show is the first command that starts with sh |
winget source l⇥ | winget source list | list is the first sub-command of source that starts with l |
winget -⇥ | winget --version | --version is the first argument defined for the root |
winget install power⇥ | winget install "Power Toys" | "Power Toys" is the first package whose Id, Name, or Moniker starts with power |
winget install "Power Toys" --version ⇥ | winget install "Power Toys" --version 0.19.2 | 0.19.2 is the highest version of Power Toys |
PowerShell Setup
Open Your PowerShell Profile
Check if your profile exists:If it returns Open the profile for editing:
False, create it:Save and Reload
- Save the file
- Reload your profile:
Command Reference
Thewinget complete command powers the tab completion feature.
Syntax
Required Arguments
| Argument | Description |
|---|---|
--word | The current word being completed - the token where the cursor is located. Can be empty to indicate no current value at the cursor. If provided, it must appear as a substring in the command line. |
--commandline | The entire current command line, including winget. Everything except the tab character should be provided to this argument. |
--position | The current position of the cursor in the command line. Can be greater than the length of the command line string to indicate the cursor is at the end. |
Completion Modes
- Replacement Mode
- Insertion Mode
When a word value is provided:Suggests completions that:
- Fit correctly at this location
- Start with the given word value
Completion Types
Based on the cursor position and context, completions can be:Sub-command
Cursor is after a command with available sub-commandsExample:
winget source ⇥Argument Specifier
Cursor is not after an argument expecting a value, and arguments are availableExample:
winget install ⇥Argument Value
Cursor is after an argument specifier that expects a value, or a positional argument is expectedExample:
winget install --source ⇥Output Format
Completions are output one per line:Bash and Zsh Support
Bash Example
For Bash, you would need to create a completion script using thecomplete builtin:
~/.bashrc or ~/.bash_completion.
Zsh Example
For Zsh, you would create a completion function:~/.zshrc.
These Bash and Zsh examples are basic implementations. You may need to adjust them based on your specific shell configuration and requirements.
Troubleshooting
Tab completion not working
Tab completion not working
Check WinGet version:Ensure you have v0.1.42241 or later.Verify profile loaded:Test complete command manually:
Completions are outdated
Completions are outdated
The completion command queries WinGet in real-time, so outdated completions usually mean your source needs updating:
PowerShell execution policy error
PowerShell execution policy error
If you get an error about execution policy when loading your profile:See about execution policies for more information.
Next Steps
Commands
Learn about all available WinGet commands
Settings
Customize WinGet behavior and preferences