Skip to content

Commit 22994ba

Browse files
authored
Merge pull request #48289 from bergerhoffer/pr-47715
Expanded the oc completion page to include the setup steps for both B…
2 parents 0aee230 + 3ddaf5d commit 22994ba

File tree

3 files changed

+45
-12
lines changed

3 files changed

+45
-12
lines changed

cli_reference/openshift_cli/configuring-cli.adoc

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,13 @@ include::_attributes/common-attributes.adoc[]
66

77
toc::[]
88

9-
// Enabling tab completion
10-
include::modules/cli-configuring-completion.adoc[leveloffset=+1]
9+
[id="cli-enabling-tab-completion"]
10+
== Enabling tab completion
11+
12+
You can enable tab completion for the Bash or Zsh shells.
13+
14+
// Enabling tab completion for Bash
15+
include::modules/cli-configuring-completion.adoc[leveloffset=+2]
16+
17+
// Enabling tab completion for Zsh
18+
include::modules/cli-configuring-completion-zsh.adoc[leveloffset=+2]
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * cli_reference/openshift_cli/configuring-cli.adoc
4+
5+
:_content-type: PROCEDURE
6+
[id="cli-enabling-tab-completion-zsh_{context}"]
7+
= Enabling tab completion for Zsh
8+
9+
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.
10+
11+
.Prerequisites
12+
13+
* You must have the OpenShift CLI (`oc`) installed.
14+
15+
.Procedure
16+
17+
* To add tab completion for `oc` to your `.zshrc` file, run the following command:
18+
+
19+
[source,terminal]
20+
----
21+
$ cat >>~/.zshrc<<EOF
22+
if [ $commands[oc] ]; then
23+
source <(oc completion zsh)
24+
compdef _oc oc
25+
fi
26+
EOF
27+
----
28+
29+
Tab completion is enabled when you open a new terminal.

modules/cli-configuring-completion.adoc

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,31 @@
44

55
:_content-type: PROCEDURE
66
[id="cli-enabling-tab-completion_{context}"]
7-
= Enabling tab completion
7+
= Enabling tab completion for Bash
88

9-
After you install the `oc` CLI tool, you can enable tab completion to
10-
automatically complete `oc` commands or suggest options when you press Tab.
9+
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.
1110

1211
.Prerequisites
1312

14-
* You must have the `oc` CLI tool installed.
13+
* You must have the OpenShift CLI (`oc`) installed.
1514
* You must have the package `bash-completion` installed.
1615
1716
.Procedure
1817

19-
The following procedure enables tab completion for Bash.
20-
21-
. Save the Bash completion code to a file.
18+
. Save the Bash completion code to a file:
2219
+
2320
[source,terminal]
2421
----
2522
$ oc completion bash > oc_bash_completion
2623
----
2724

28-
. Copy the file to `/etc/bash_completion.d/`.
25+
. Copy the file to `/etc/bash_completion.d/`:
2926
+
3027
[source,terminal]
3128
----
3229
$ sudo cp oc_bash_completion /etc/bash_completion.d/
3330
----
3431
+
35-
You can also save the file to a local directory and source it from your
36-
`.bashrc` file instead.
32+
You can also save the file to a local directory and source it from your `.bashrc` file instead.
3733

3834
Tab completion is enabled when you open a new terminal.

0 commit comments

Comments
 (0)