$ oc completion bash > oc_bash_completion
You can enable tab completion for the Bash or Zsh shells.
After you install the OpenShift CLI (oc
), you can enable tab completion to automatically complete oc
commands or suggest options when you press Tab. The following procedure enables tab completion for the Bash shell.
You must have the OpenShift CLI (oc
) installed.
You must have the package bash-completion
installed.
Save the Bash completion code to a file:
$ oc completion bash > oc_bash_completion
Copy the file to /etc/bash_completion.d/
:
$ sudo cp oc_bash_completion /etc/bash_completion.d/
You can also save the file to a local directory and source it from your .bashrc
file instead.
Tab completion is enabled when you open a new terminal.
After you install the OpenShift CLI (oc
), you can enable tab completion to automatically complete oc
commands or suggest options when you press Tab. The following procedure enables tab completion for the Zsh shell.
You must have the OpenShift CLI (oc
) installed.
To add tab completion for oc
to your .zshrc
file, run the following command:
$ cat >>~/.zshrc<<EOF
autoload -Uz compinit
compinit
if [ $commands[oc] ]; then
source <(oc completion zsh)
compdef _oc oc
fi
EOF
Tab completion is enabled when you open a new terminal.