Skip to content

Commit

Permalink
Documentation and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
aohoyd authored and SimonTheLeg committed Jul 2, 2024
1 parent e02e8cd commit efad56e
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
34 changes: 33 additions & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,34 @@ 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
# Currently supported shells: zsh, bash
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
Expand All @@ -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:
Expand Down
7 changes: 7 additions & 0 deletions cmd/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down
1 change: 1 addition & 0 deletions cmd/shellwrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit efad56e

Please sign in to comment.