|
2 | 2 | The Kubebuilder completion script can be generated with the command `kubebuilder completion [bash|fish|powershell|zsh]`.
|
3 | 3 | Note that sourcing the completion script in your shell enables Kubebuilder autocompletion.
|
4 | 4 |
|
| 5 | +## Bash |
| 6 | + |
5 | 7 | <aside class="note">
|
6 | 8 | <h1>Prerequisites for Bash</h1>
|
7 | 9 |
|
8 | 10 | The completion Bash script depends on [bash-completion](https://github.com/scop/bash-completion), which means that you have to install this software first (you can test if you have bash-completion already installed). Also, ensure that your Bash version is 4.1+.
|
9 | 11 |
|
| 12 | +```bash |
| 13 | +$ bash --version |
| 14 | +``` |
| 15 | + |
10 | 16 | </aside>
|
11 | 17 |
|
| 18 | +- Check that bash is an available shell: |
12 | 19 |
|
13 |
| -- Once installed, go ahead and add the path `/usr/local/bin/bash` in the `/etc/shells`. |
| 20 | + ```bash |
| 21 | + cat /etc/shells | grep '^.*/bash' |
| 22 | + ``` |
14 | 23 |
|
15 |
| - `echo “/usr/local/bin/bash” > /etc/shells` |
| 24 | +- If not, add bash to `/etc/shells`. For example, if bash is at `/usr/local/bin/bash`: |
16 | 25 |
|
17 |
| -- Make sure to use installed shell by current user. |
| 26 | + ```bash |
| 27 | + echo "/usr/local/bin/bash" >> /etc/shells |
| 28 | + ``` |
18 | 29 |
|
19 |
| - `chsh -s /usr/local/bin/bash` |
| 30 | +- Make sure the current user uses bash as their shell. |
20 | 31 |
|
21 |
| -- Add following content in /.bash_profile or ~/.bashrc |
| 32 | + ```bash |
| 33 | + chsh -s /usr/local/bin/bash |
| 34 | + ``` |
| 35 | + |
| 36 | +- Add following content to `~/.bash_profile` or `~/.bashrc` |
| 37 | + |
| 38 | + ```bash |
| 39 | + # kubebuilder autocompletion |
| 40 | + if [ -f /usr/local/share/bash-completion/bash_completion ]; then |
| 41 | + . /usr/local/share/bash-completion/bash_completion |
| 42 | + fi |
| 43 | + . <(kubebuilder completion bash) |
| 44 | + ``` |
22 | 45 |
|
23 |
| -``` |
24 |
| -# kubebuilder autocompletion |
25 |
| -if [ -f /usr/local/share/bash-completion/bash_completion ]; then |
26 |
| -. /usr/local/share/bash-completion/bash_completion |
27 |
| -fi |
28 |
| -. <(kubebuilder completion bash) |
29 |
| -``` |
30 | 46 | - Restart terminal for the changes to be reflected or `source` the changed bash file.
|
31 | 47 |
|
32 |
| -<aside class="note"> |
33 |
| -<h1>Zsh</h1> |
| 48 | + ```bash |
| 49 | + . ~/.bash_profile |
| 50 | + ``` |
34 | 51 |
|
35 |
| -Follow a similar protocol for `zsh` completion. |
| 52 | +## Zsh |
36 | 53 |
|
37 |
| -</aside> |
| 54 | +Follow a similar protocol for `zsh` completion. |
38 | 55 |
|
39 |
| -<aside class="note"> |
40 |
| -<h1>Fish</h1> |
| 56 | +## Fish |
41 | 57 |
|
| 58 | +``` |
42 | 59 | source (kubebuilder completion fish | psub)
|
43 |
| - |
44 |
| -</aside> |
| 60 | +``` |
0 commit comments