Skip to content
Myr

Update the bash completion example for kubectl (#645)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Bilal Amarni · committed by Eric Paris · parent 6644d46 · Browse files · 1 file+6 added−5 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+6 added−5 removed

  • other:+6 added−5 removed

1 file+6 added−5 removed

modified:bash_completions.md+6 added-5 removed
4 unmodified lines
5```go6package main78import (9 "io/ioutil"10 "os"9 "io/ioutil"10 "os"1112 "github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl/cmd"12 "k8s.io/kubernetes/pkg/kubectl/cmd"13 "k8s.io/kubernetes/pkg/kubectl/cmd/util"14)1516func main() {16 kubectl := cmd.NewFactory(nil).NewKubectlCommand(os.Stdin, ioutil.Discard, ioutil.Discard)17 kubectl.GenBashCompletionFile("out.sh")17 kubectl := cmd.NewKubectlCommand(util.NewFactory(nil), os.Stdin, ioutil.Discard, ioutil.Discard)18 kubectl.GenBashCompletionFile("out.sh")19}20```2122`out.sh` will get you completions of subcommands and flags. Copy it to `/etc/bash_completion.d/` as described [here](https://debian-administration.org/article/316/An_introduction_to_bash_completion_part_1) and reset your terminal to use autocompletion. If you make additional annotations to your code, you can get even more intelligent and flexible behavior.
199 unmodified lines