LinuxCommandLibrary

pulumi-gen-completion

Generate shell completion scripts for Pulumi

TLDR

Generate completion scripts

$ pulumi gen-completion [bash|zsh|fish]
copy

SYNOPSIS

pulumi-gen-completion shell_name [OPTIONS]

PARAMETERS

shell_name
    Specifies the target shell for which to generate completion scripts. Valid values typically include bash, zsh, fish, and powershell.

--help
    Displays help information for the command, detailing its usage and available options.

DESCRIPTION

The pulumi-gen-completion command, conceptually referencing the functionality provided by pulumi completion (or pulumi gen completion in older versions) of the Pulumi CLI, is used to generate shell auto-completion scripts. These scripts enable tab-completion for Pulumi commands, options, and arguments within various shell environments.

When executed, the command outputs the completion script to standard output, which users typically redirect to a file in an appropriate system or user-specific directory (e.g., /etc/bash_completion.d/ for Bash, or ~/.zsh/completion/ for Zsh). This feature significantly enhances productivity by reducing typing and potential errors when interacting with the Pulumi command-line interface.

CAVEATS

For the generated shell completion to function correctly, the output file containing the completion script must be sourced by your shell. This commonly involves adding a specific line to your shell's configuration file (e.g., ~/.bashrc, ~/.zshrc, ~/.config/fish/config.fish, or $PROFILE for PowerShell).

The exact location where completion files should be placed and how they are sourced can vary significantly between different shell versions and operating systems.

This command inherently requires the Pulumi CLI to be installed and accessible in your system's PATH.

COMMON USAGE EXAMPLES

Here are typical ways to generate and enable Pulumi shell completions for various shells:

Bash:
# Generate and save the completion script
pulumi-gen-completion bash > /etc/bash_completion.d/pulumi.sh
# Then, ensure it's sourced in your ~/.bashrc or ~/.profile
source /etc/bash_completion.d/pulumi.sh

Zsh:
# Create a completion directory if it doesn't exist
mkdir -p ~/.zsh/completion
# Generate and save the completion script
pulumi-gen-completion zsh > ~/.zsh/completion/_pulumi
# Then, add the following to your ~/.zshrc
fpath=(~/.zsh/completion $fpath)
autoload -Uz compinit && compinit

Fish:
# Generate and save the completion script
pulumi-gen-completion fish > ~/.config/fish/completions/pulumi.fish
(Fish automatically loads completion files from this directory)

PowerShell:
# Generate and append the completion script to your PowerShell profile
pulumi-gen-completion powershell | Out-File -FilePath $PROFILE -Append

HISTORY

The ability to generate shell completions has been an integral part of the Pulumi CLI since its early versions, initially often accessible via pulumi gen completion and later streamlined to pulumi completion. This feature was developed to improve the user experience by providing an interactive and efficient way to interact with the Pulumi command-line tools, reflecting a common trend in modern developer tooling for enhanced usability and productivity.

SEE ALSO

pulumi(1), bash(1), zsh(1), fish(1), powershell(1)

Copied to clipboard