PitchHut logo
Effortlessly switch Google Cloud configurations in your terminal.
Pitch

gsw is a lightweight Bash/Zsh plugin designed to simplify the management of Google Cloud configurations. With its session-based switching, users can switch configurations in the current terminal tab without affecting others, reducing the risks associated with managing multiple projects simultaneously. Enjoy features like auto-completion and zero dependencies for a seamless experience.

Description

gsw (Google Switch) is a lightweight Bash/Zsh plugin designed to simplify the management of Google Cloud SDK configurations. With gsw, switching between multiple configurations is effortless and immediate, promoting safer operations when working across various Google Cloud projects.

Key Features

  • Session Isolation: By default, gsw switches configurations only for the current terminal session, eliminating the risk of accidental command execution in the wrong project across multiple open terminals.
  • Global Switching Option: Use the -g option for occasions when a global configuration switch is necessary, affecting all terminal tabs.
  • Auto-Completion: Enhance productivity with tab completion for existing gcloud configurations in both Bash and Zsh environments.
  • Zero Dependencies: Leveraging pure shell functions, gsw has no external dependencies, making it lightweight and efficient.

How Does gsw Operate?

The functionality of gsw revolves around the CLOUDSDK_ACTIVE_CONFIG_NAME environment variable. When a configuration is specified using gsw <config>, it exports this variable to the current shell session. As a result, the Google Cloud SDK prioritizes this session-specific variable over the global configuration, providing a straightforward and safe method for context switching without complex setups.

Comparison Table

Featuregswgcloud activatedirenv
ScopeSession (Current tab)Global (All tabs)Directory-based
SwitchingAd-hoc (Anywhere)Ad-hoc (Anywhere)Automatic (On cd)
SafetyHigh (Isolated)Low (Side effects)High (Context-aware)
SetupZeroZeroNeeds .envrc files

Usage Examples

To switch to a specific configuration for the current session:

gsw my-work-profile

For a global switch affecting all terminal instances:

gsw -g my-personal-profile

To view available configurations and usage help, simply run:

gsw

gsw is designed for those who manage multiple Google Cloud projects, ensuring seamless and safe configuration switching across various terminal sessions.

0 comments

No comments yet.

Sign in to be the first to comment.