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.
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,
gswswitches 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
-goption 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,
gswhas 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
| Feature | gsw | gcloud activate | direnv |
|---|---|---|---|
| Scope | Session (Current tab) | Global (All tabs) | Directory-based |
| Switching | Ad-hoc (Anywhere) | Ad-hoc (Anywhere) | Automatic (On cd) |
| Safety | High (Isolated) | Low (Side effects) | High (Context-aware) |
| Setup | Zero | Zero | Needs .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.
No comments yet.
Sign in to be the first to comment.