The kubeswitch installation consists of both a switcher binary and a shell script which needs to be sourced.
NOTE: to invoke kubeswitch, do not call the switcher binary directly from the command line.
Instead, use the sourced shell function as described in source the shell function.
NOTE: fish users please follow install via Github releases as the shell script only works for zsh and bash shells.
Install the switcher binary with homebrew.
brew install academician/switch/switch
Next, follow required: source the shell function.
NOTE: fish users please follow install via Github releases as the shell script only works for zsh and bash shells.
Mac users can also install both switch.sh and switcher from MacPorts
sudo port selfupdate
sudo port install kubeswitch
Next, follow required: source the shell function.
Download the switcher binary
OS=linux # Pick the right os: linux, darwin (intel only)
VERSION=0.9.4-academician.0 # Pick the current version.
curl -L -o /usr/local/bin/switcher https://github.com/academician/kubeswitch/releases/download/${VERSION}/switcher_${OS}_amd64
chmod +x /usr/local/bin/switcherIf you are using Windows, go to the release webpage using you browser and download the windows binary: https://github.com/academician/kubeswitch/releases/
Then copy it to a folder available in your path. To add a folder to your path, you can use the Environment Variables tool for the Windows' PowerToys: https://learn.microsoft.com/en-us/windows/powertoys/environment-variables
If you need to add a folder to the path for the current powershell session, you can run $env:Path += ';C:\myfolder'
Next, follow required: source the shell function.
go get github.com/academician/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.
Next, follow required: source the shell function.
Source the shell function which is used to call the switcher binary.
For zsh/bash the name of the shell function is switch and for fish its kubeswitch.
Additionally, installs the command completion script.
echo 'source <(switcher init bash)' >> ~/.bashrc
# optionally use alias `s` instead of `switch`
echo 'alias s=switch' >> ~/.bashrc
echo 'complete -o default -F __start_switcher s' >> ~/.bashrcecho 'source <(switcher init zsh)' >> ~/.zshrc
# optionally use alias `s` instead of `switch`
echo 'alias s=switch' >> ~/.zshrc
# optionally use command completion
echo 'source <(switch completion zsh)' >> ~/.zshrcFish shell have a built-in switch function. Hence, differently from zsh shells, the kubeswitch function is called kubeswitch.
echo 'switcher init fish | source' >> ~/.config/fish/config.fish
# optionally use alias `s` instead of `kubeswitch` (add to config.fish)
function s --wraps switcher
kubeswitch $argv;
endPowershell shell have a built-in switch function. Hence, differently from zsh shells, the kubeswitch function is called kubeswitch.
switcher_windows_amd64.exe init powershell >> $PROFILE
# add this for the autocomplete to work
echo 'Register-ArgumentCompleter -CommandName ''switcher_windows_amd64'' -ScriptBlock $__switcherCompleterBlock' >> $PROFILE
echo 'Register-ArgumentCompleter -CommandName ''kubeswitch'' -ScriptBlock $__switcherCompleterBlock' >> $PROFILE
# optionally use alias `s` instead of `kubeswitch` (add to $PROFILE)
echo "" >> $PROFILE
echo "Set-Alias -Name s -Value kubeswitch" >> $PROFILE
echo 'Register-ArgumentCompleter -CommandName ''s'' -ScriptBlock $__switcherCompleterBlock' >> $PROFILE
# source your profile again
. $PROFILEIf you installed kubeswitch correctly, you can run the command switch (zsh, bash) or kubeswitch (fish, powershell) or alternatively the alias s from the terminal.
In case the terminal can't find the function, you might need to open another terminal or re-source your config file (.zshrc,.bashrc,...).
That should display the contexts the tool can find with the default configuration.
If you get the error Error: you need to point kubeswitch to a kubeconfig file or do not see all
desired kubeconfig contexts that you want to choose from, follow
kubeconfig stores for the configuration.