LinuxCommandLibrary

gcrane-completion

Generate shell completion script for gcrane

TLDR

Generate the autocompletion script for your shell

$ gcrane completion [shell_name]
copy

Disable completion descriptions
$ gcrane completion [shell_name] --no-descriptions
copy

Load completions in your current shell session (bash/zsh)
$ source <(gcrane completion bash/zsh)
copy

Load completions in your current shell session (fish)
$ gcrane completion fish | source
copy

Load completions for every new session (bash)
$ gcrane completion bash > /etc/bash_completion.d/gcrane
copy

Load completions for every new session (zsh)
$ gcrane completion zsh > "${fpath[1]}/_gcrane"
copy

Load completions for every new session (fish)
$ gcrane completion fish > ~/.config/fish/completions/gcrane.fish
copy

Display help
$ gcrane completion [shell_name] [[-h|--help]]
copy

SYNOPSIS

gcrane-completion <SHELL_NAME>

PARAMETERS

SHELL_NAME
    The name of the shell for which to generate the completion script. Common valid values include bash, zsh, fish, or powershell. The generated script is printed to standard output.

DESCRIPTION

The gcrane-completion command, typically a wrapper script or a conceptual reference to the gcrane completion subcommand, is designed to generate shell auto-completion scripts for the gcrane utility.

The gcrane tool itself is used for interacting with Google Container Registry (GCR) and Artifact Registry. By executing this command with a specified shell name (e.g., bash, zsh), users can obtain a script that, when sourced into their shell configuration (like .bashrc or .zshrc), provides intelligent auto-completion for gcrane commands, subcommands, and flags.

This feature significantly enhances command-line productivity by reducing typing and preventing common syntax errors, making gcrane more user-friendly for routine operations.

CAVEATS

To activate the completion functionality, the generated script must be sourced into your shell's configuration (e.g., ~/.bashrc, ~/.zshrc, ~/.config/fish/completions/gcrane.fish).

The gcrane executable must be installed and accessible in your system's PATH for the completion to work correctly.

PowerShell completion might require specific PowerShell module installations or versions depending on your environment.

ACTIVATION EXAMPLES

To permanently enable shell completion, you typically add a line to your shell's configuration file:

For Bash:
echo 'source <(gcrane-completion bash)' >> ~/.bashrc
source ~/.bashrc

For Zsh:
echo 'autoload -Uz compinit; compinit'
echo 'source <(gcrane-completion zsh)' >> ~/.zshrc
source ~/.zshrc

Note: If gcrane-completion is not a direct executable but rather gcrane completion, replace gcrane-completion with gcrane completion in the above commands.

OUTPUT

The command prints the full shell completion script to standard output. Users often redirect this output to a file (e.g., gcrane-completion bash > /etc/bash_completion.d/gcrane) or source it directly using process substitution (e.g., source <(gcrane-completion bash)).

HISTORY

The ability to generate shell completion scripts is a standard feature in many modern command-line tools, particularly those built with the Go language using libraries like Cobra.

While gcrane-completion as a standalone command might be a specific wrapper, the underlying gcrane completion subcommand was integrated relatively early in the gcrane tool's development. gcrane itself is part of the go-containerregistry project and extends the base crane tool with Google Cloud-specific authentication and registry interactions.

SEE ALSO

gcrane(1), crane(1), bash(1), zsh(1), fish(1)

Copied to clipboard