Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
OPENSHIFT COOKBOOK

You're reading from   OPENSHIFT COOKBOOK Over 100 hands-on recipes that will help you create, deploy, manage, and scale OpenShift applications

Arrow left icon
Product type Paperback
Published in Oct 2014
Publisher Packt
ISBN-13 9781783981205
Length 430 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Shekhar Gulati Shekhar Gulati
Author Profile Icon Shekhar Gulati
Shekhar Gulati
Arrow right icon
View More author details
Toc

Table of Contents (14) Chapters Close

Preface 1. Getting Started with OpenShift FREE CHAPTER 2. Managing Domains 3. Creating and Managing Applications 4. Using MySQL with OpenShift Applications 5. Using PostgreSQL with OpenShift Applications 6. Using MongoDB and Third-party Database Cartridges with OpenShift Applications 7. OpenShift for Java Developers 8. OpenShift for Python Developers 9. OpenShift for Node.js Developers 10. Continuous Integration for OpenShift Applications 11. Logging and Scaling Your OpenShift Applications A. Running OpenShift on a Virtual Machine
Index

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:

  1. Run the rhc setup command again with the autocomplete option:
    $ rhc setup --autocomplete
    
  2. 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
    
  3. 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.
  4. 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
You have been reading a chapter from
OPENSHIFT COOKBOOK
Published in: Oct 2014
Publisher: Packt
ISBN-13: 9781783981205
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image