Skip to content

pXius/gcloud-zsh-complete

Repository files navigation

gcloud-zsh-complete

A tool to generate comprehensive Zsh completion scripts for the Google Cloud CLI (gcloud).

Description

This project automates the creation of Zsh tab-completion for gcloud commands by crawling the CLI's metadata. It generates a _gcloud completion script that supports nested subcommands and descriptions, enabling efficient command-line usage.

Features

  • Extracts command tree and flags from gcloud CLI metadata
  • Generates recursive Zsh completion with descriptions
  • Automated weekly updates via CI/CD
  • No external dependencies (uses Python standard library)

Prerequisites

  • Python 3.x
  • Google Cloud CLI (gcloud) installed and authenticated

Installation

  1. Clone this repository:

    git clone https://github.com/yourusername/gcloud-zsh-complete.git
    cd gcloud-zsh-complete
  2. Ensure gcloud CLI is installed (see official docs).

Usage

Manual Generation

  1. Run the crawler to extract gcloud metadata:

    python generate_json_from_gcloud_cli.py

    This creates gcloud_completions.json.

  2. Generate the Zsh completion script:

    python generate_zsh_from_json.py gcloud_completions.json _gcloud
  3. Source the completion in your Zsh shell:

    source _gcloud

    Or add it to your .zshrc for permanent loading.

Automated Updates

The GitHub Actions workflow runs weekly (Sundays) to generate and release updated completions. Releases are tagged with the gcloud CLI version (e.g., 123.0.0) and include the _gcloud file as an asset.

Disclaimer

The generated completions are based on the gcloud CLI metadata accessible under the authenticated account used during generation. This may not include all possible commands if certain components or permissions are restricted. The released versions reflect the latest automated run and might not cover everything. However, the pipeline defaults still cover most command combinations and custom runs are not required in most cases. For comprehensive completions tailored to your account, run the scripts manually: first python generate_json_from_gcloud_cli.py to extract metadata, then python generate_zsh_from_json.py gcloud_completions.json _gcloud to generate the script.

Contributing

Contributions are welcome! Please open issues or pull requests for improvements.

License

This project is licensed under the MIT License. See LICENSE file for details.

About

A tool to generate comprehensive Zsh completion scripts for the Google Cloud CLI (gcloud).

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages