A minimal shell plugin for kubectx-style Google Cloud project switching.
Uses fzf for interactive fuzzy project selection and wraps gcloud project switching into two fast commands.
| Command | Description |
|---|---|
gx |
Permanently switch the active project via gcloud config set project |
tgx |
Temporarily switch the project for the current shell session only (sets CLOUDSDK_CORE_PROJECT) |
git clone https://github.com/jesbinjoseph/gcloudx.git
cd gcloudx
bash install.shinstall.sh copies gx.plugin.zsh to ~/.gx/ and adds a source line to ~/.zshrc and/or ~/.bashrc.
Restart your shell, or source the plugin manually:
source ~/.gx/gx.plugin.zshbash uninstall.shRemoves ~/.gx/ and cleans the source line from ~/.zshrc / ~/.bashrc.
Run gx to permanently switch your active project:
$ gx
> my-project-a
my-project-b
my-project-c
Switched to project: my-project-a
Run tgx to switch only for the current shell session:
$ tgx
> my-project-b
CLOUDSDK_CORE_PROJECT=my-project-b (session only)
Press Esc or Ctrl-C in fzf to cancel without making any changes.
- Two shell functions, no config files, no abstractions.
- No dependencies beyond
gcloudandfzf. - POSIX-compatible (
[ ]tests, works in both zsh and bash). - Cancelling fzf selection (empty result) is a no-op.