Mac and Linux users can install both the switch.sh
script and the switcher
binary with homebrew
.
$ brew install danielfoehrkn/switch/switch
Source the switch.sh
script from the homebrew
installation path.
$ INSTALLATION_PATH=$(brew --prefix switch) && source $INSTALLATION_PATH/switch.sh
Mac users can also install both switch.sh
and switcher
from MacPorts
$ sudo port selfupdate
$ sudo port install kubeswitch
Source the switch.sh
script from the MacPorts root (/opt/local).
$ source /opt/local/libexec/kubeswitch/switch.sh
$ go get github.com/danielfoehrkn/kubeswitch
From the repository root run make build-switcher
.
This builds the binaries to /hack/switch/
.
Copy the build binary for your OS / Architecture to e.g. /usr/local/bin
and source the switch script from /hack/switch/switch.sh
.
Download the switch script and the switcher binary.
OS=linux # Pick the right os: linux, darwin (intel only)
VERSION=0.7.0 # Pick the current version.
curl -L -o /usr/local/bin/switcher https://github.com/danielfoehrKn/kubeswitch/releases/download/${VERSION}/switcher_${OS}_amd64
chmod +x /usr/local/bin/switcher
curl -L -o /usr/local/bin/switch.sh https://github.com/danielfoehrKn/kubeswitch/releases/download/${VERSION}/switch.sh
chmod +x /usr/local/bin/switch.sh
Source switch.sh
in .bashrc
/.zsh
via:
$ source /usr/local/bin/switch.sh
Please see here how to install command completion for bash and zsh shells.
This completes both the kubeswitch
commands as well as the context names.
To not alter the current shell session, kubeswitch
does not spawn a new sub-shell.
You need to configure a cleanup handler if you care to remove temporary kubeconfig files from $HOME/.kube/.switch_tmp
when the shell session
ends (close the terminal window, or exit
is called).
For zsh
, please source this script from your .zshrc
file.