diff --git a/Readme.md b/Readme.md index 8fba452..c09df07 100644 --- a/Readme.md +++ b/Readme.md @@ -71,6 +71,10 @@ Please do not rename or alias this binary, it is not be called by the user direc ### 2. Install the konf shellwrapper +Depending on whether you are using zsh/bash or fish, please use the following: + +#### A) zsh/bash + Add the following to your `.zshrc` / `.bashrc` and restart your shell or re-source this file: ```sh @@ -78,11 +82,23 @@ Add the following to your `.zshrc` / `.bashrc` and restart your shell or re-sour source <(konf-go shellwrapper zsh) ``` +#### B) fish + +Add the following to your `config.fish` and restart your shell or re-source this file: + +```sh +konf-go shellwrapper fish | source +``` + This will install a shellwrapper called `konf`, which you can use like any command. The wrapper can also be aliased if need be. ### Customizations to Have a Good Time -A collection of optional settings to improve quality of life with konf. These can be added to your `.zshrc` / `.bashrc`: +A collection of optional settings to improve quality of life with konf. + +#### A) zsh/bash + +These can be added to your `.zshrc` / `.bashrc`: ```sh # Autocompletion. Currently supported shells: zsh, bash @@ -96,6 +112,22 @@ alias kctx="konf set" alias kns="konf ns" ``` +#### B) fish + +These can be added to your `config.fish`: + +```sh +# Autocompletion +konf completion fish | source + +# Open last konf on new shell session +set -x KUBECONFIG (konf --silent set -) + +# Alias +abbr --add --global -- kctx 'konf set' +abbr --add --global -- kns 'konf ns' +``` + ## Usage Before any kubeconfig can be used with konf you have to import it: diff --git a/cmd/completion.go b/cmd/completion.go index 385964a..5fbf9c7 100644 --- a/cmd/completion.go +++ b/cmd/completion.go @@ -41,6 +41,13 @@ Zsh: # To load completions for each session, add this to your zshrc: source <(konf completion zsh) +fish: + + $ konf completion fish | source + + # To load completions for each session, execute once: + $ konf completion fish > ~/.config/fish/completions/konf.fish + `, DisableFlagsInUseLine: true, ValidArgs: []string{"bash", "zsh", "fish"}, diff --git a/cmd/shellwrapper.go b/cmd/shellwrapper.go index 50d09d7..c96521d 100644 --- a/cmd/shellwrapper.go +++ b/cmd/shellwrapper.go @@ -79,6 +79,7 @@ function konf -w konf-go set -gx KUBECONFIG (string replace -r '^KUBECONFIGCHANGE:' '' $res) else # this makes --help work + # because fish does not support bracketed vars, we use printf instead printf "%s\n" $res end end