2019-02-22 08:49:56 -05:00
// Module included in the following assemblies:
//
2019-10-02 11:30:49 -04:00
// * cli_reference/openshift_cli/configuring-cli.adoc
2019-02-22 08:49:56 -05:00
2023-10-30 10:13:25 -04:00
:_mod-docs-content-type: PROCEDURE
2019-05-13 08:55:00 +10:00
[id="cli-enabling-tab-completion_{context}"]
2022-07-13 14:18:06 +03:00
= Enabling tab completion for Bash
2019-02-22 08:49:56 -05:00
2022-07-13 14:18:06 +03:00
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.
2019-02-22 08:49:56 -05:00
.Prerequisites
2022-07-13 14:18:06 +03:00
* You must have the OpenShift CLI (`oc`) installed.
2021-06-22 15:29:52 -04:00
* You must have the package `bash-completion` installed.
2019-02-22 08:49:56 -05:00
.Procedure
2022-07-13 14:18:06 +03:00
. Save the Bash completion code to a file:
2019-02-22 08:49:56 -05:00
+
2020-08-04 22:42:35 -04:00
[source,terminal]
2019-02-22 08:49:56 -05:00
----
$ oc completion bash > oc_bash_completion
----
2022-07-13 14:18:06 +03:00
. Copy the file to `/etc/bash_completion.d/`:
2019-02-22 08:49:56 -05:00
+
2020-08-04 22:42:35 -04:00
[source,terminal]
2019-02-22 08:49:56 -05:00
----
$ sudo cp oc_bash_completion /etc/bash_completion.d/
----
+
2022-07-13 14:18:06 +03:00
You can also save the file to a local directory and source it from your `.bashrc` file instead.
2019-02-22 08:49:56 -05:00
Tab completion is enabled when you open a new terminal.