- OpenShift Cookbook
- Shekhar Gulati
- 464字
- 2021-08-05 17:37:38
Enabling the autocomplete feature in an rhc command-line client
The rhc
command-line utility supports autocompletion. This involves rhc
predicting a command that the user wants to type in without them actually typing it completely. This is very helpful for new users who do not know all the commands supported by rhc
. In this recipe, you will learn how to enable autocomplete for the rhc
command-line client.
Note
The autocomplete feature does not work for Windows Terminal.
Getting ready
To step through this recipe, you will need to have rhc
installed on your machine. Refer to the Installing the OpenShift rhc command-line client recipe for instructions.
How to do it…
To enable autocompletion, perform the following steps:
- Run the
rhc setup
command again with theautocomplete
option:$ rhc setup --autocomplete
- The previous step will generate a file named
bash_autocomplete
in the.openshift
folder at~/.openshift
. To enable autocompletion, you have to add the~/.openshift/bash_autocomplete
line to the.bashrc
or.bash_profile
file present in your user's home directory. The.bashrhc
file on my Fedora box is as follows:# .bashrc . ~/.openshift/bash_autocomplete # Source global definitions if [ -f /etc/bashrc ]; then . /etc/bashrc fi # User specific aliases and functions
- Note that on Mac OS X, you have to add
~/.openshift/bash_autocomplete
to your~/.bash_profile
. On Mac OS X, the new Terminal windows and tabs are always considered login shells, so this is a necessary step for OS X users. - Reload or restart the shell to allow these changes to take effect.
How it works…
You should try to understand what you have done in the preceding section. In step 1, you ran the setup
command with the autocomplete
option. This generated a bash script called bash_autocomplete
in the .openshift
folder at ~/.openshift
. This bash script defines a custom completion function called _rhc
for the rhc
command-line client. Bash will execute this function when the rhc
tab key is typed at the prompt and will display possible completions.
In step 2, you sourced the bash_autocomplete
file by adding ~/.openshift/bash_autocomplete
to the .bashrc
script. This will make sure that the autocompletion functionality is available for each shell.
Finally, in step 3, you restarted the shell to load the _rhc
function. Now, if you type rhc
and then press the Tab key, it will show you all the rhc
commands:
$ rhc account app-tidy deployment-list member-list // removed all commands for brevity
There's more…
Most of the rhc
commands have options, which you can provide. To view all the options for a command, type in --
and press Tab. For example, to view all the rhc setup
command options, type in rhc setup --
and press Tab:
$ rhc setup -- --autocomplete --clean --create-token --no-create-token --server
See also
- The Setting up an OpenShift account using rhc recipe
- 通信網(wǎng)絡(luò)基礎(chǔ)與設(shè)備
- Web安全防護(hù)指南:基礎(chǔ)篇
- 連接未來:從古登堡到谷歌的網(wǎng)絡(luò)革命
- 網(wǎng)絡(luò)創(chuàng)新指數(shù)研究
- 局域網(wǎng)組建、管理與維護(hù)項(xiàng)目教程(Windows Server 2003)
- Drush User’s Guide
- 2018網(wǎng)信發(fā)展報(bào)告
- C/C++串口通信:典型應(yīng)用實(shí)例編程實(shí)踐
- Master Apache JMeter:From Load Testing to DevOps
- 夢(mèng)工廠之材質(zhì)N次方:Maya材質(zhì)手冊(cè)
- 圖解物聯(lián)網(wǎng)
- 商業(yè)的本質(zhì)和互聯(lián)網(wǎng)
- 黑客與反黑工具使用詳解
- Building Microservices with Spring
- 巧學(xué)活用CISCO網(wǎng)絡(luò)典型配置