Makes it easier to switch configurations in the gcloud
CLI.
Idea and patterns stolen from ahmetb's kubectx. Go check it out, it's awesome!
gcloud init
your configurations, then:
gconf : list available configs
gconf <NAME> : activate config
gconf - : switch to previously active config
gconf -h,--help : show this message
Since gconf
is written in Bash, you should be able to install
it to any POSIX environment that has Bash installed.
- Download the
gconf
script. - Either:
- save it somewhere in your
PATH
, - or save it to a directory, then create symlinks to
gconf
from somewhere in yourPATH
, like/usr/local/bin
- save it somewhere in your
- Make
gconf
executable (chmod +x ...
) - Install bash/zsh/fish completion scripts.
- For zsh:
The completion scripts have to be in a path that belongs to$fpath
. Either link or copy them to an existing folder.
If using oh-my-zsh you can do as follows:If autocomplete isn't loaded on logout/login, try the following:git clone https://github.com/uhinze/gconf.git ~/.gconf mkdir -p ~/.oh-my-zsh/completions chmod -R 755 ~/.oh-my-zsh/completions ln -s ~/.gconf/completion/gconf.zsh ~/.oh-my-zsh/completions/_gconf.zsh
This refreshes the compinit dumpfile.compinit -d $ZSH_COMPDUMP
- For bash:
git clone https://github.com/uhinze/gconf.git ~/.gconf COMPDIR=$(pkg-config --variable=completionsdir bash-completion) ln -sf ~/.gconf/completion/gconf.bash $COMPDIR/gconf
- For fish:
mkdir -p ~/.config/fish/completions ln -s /opt/gconf/completion/gconf.fish ~/.config/fish/completions/
- For zsh:
If you want gconf
to present you an interactive menu
with fuzzy searching, you just need to install
fzf
in your PATH.
If you have fzf
installed, but want to opt out of using this feature, set the environment variable GCONF_IGNORE_FZF=1
.
If you like to customize the colors indicating the current namespace or context, set the environment variables GCONF_CURRENT_FGCOLOR
and GCONF_CURRENT_BGCOLOR
(refer color codes here):
export GCONF_CURRENT_FGCOLOR=$(tput setaf 6) # blue text
export GCONF_CURRENT_BGCOLOR=$(tput setab 7) # white background
Colors in the output can be disabled by setting the
NO_COLOR
environment variable.