sigs.k8s.io/cluster-api@v1.7.1/docs/book/src/clusterctl/commands/completion.md (about) 1 # clusterctl completion 2 3 The `clusterctl completion` command outputs shell completion code for the 4 specified shell (bash or zsh). The shell code must be evaluated to provide 5 interactive completion of clusterctl commands. 6 7 ## Bash 8 9 <aside class="note"> 10 11 <h1>Note</h1> 12 13 This requires the bash-completion framework. 14 15 </aside> 16 17 To install `bash-completion` on macOS, use Homebrew: 18 19 ```bash 20 brew install bash-completion 21 ``` 22 23 Once installed, bash_completion must be evaluated. This can be done by adding 24 the following line to the `~/.bash_profile`. 25 26 ```bash 27 [[ -r "$(brew --prefix)/etc/profile.d/bash_completion.sh" ]] && . "$(brew --prefix)/etc/profile.d/bash_completion.sh" 28 ``` 29 30 If bash-completion is not installed on Linux, please install the 31 'bash-completion' package via your distribution's package manager. 32 33 You now have to ensure that the clusterctl completion script gets sourced in 34 all your shell sessions. There are multiple ways to achieve this: 35 36 - Source the completion script in your `~/.bash_profile` file: 37 ```bash 38 source <(clusterctl completion bash) 39 ``` 40 - Add the completion script to the /usr/local/etc/bash_completion.d directory: 41 ```bash 42 clusterctl completion bash >/usr/local/etc/bash_completion.d/clusterctl 43 ``` 44 45 ## Zsh 46 47 <aside class="note"> 48 49 <h1>Note</h1> 50 51 Zsh completions are only supported in versions of zsh >= 5.2 52 53 </aside> 54 55 The clusterctl completion script for Zsh can be generated with the command 56 `clusterctl completion zsh`. 57 58 If shell completion is not already enabled in your environment you will need to 59 enable it. You can execute the following once: 60 61 ```zsh 62 echo "autoload -U compinit; compinit" >> ~/.zshrc 63 ``` 64 65 To load completions for each session, execute once: 66 67 ```zsh 68 clusterctl completion zsh > "${fpath[1]}/_clusterctl" 69 ``` 70 71 You will need to start a new shell for this setup to take effect.