IBM Support

Cloud Pak for Security: How to enable tab auto completion for the cpctl command-line tool

How To


Summary

The document explains how to enable tab auto completion for the Cloud Pak for Security (CP4S) cpctl command-line tool.

Objective

Enable tab auto completion for the Cloud Pak for Security cpctl command-line tool for the bash shell environment.
This feature is also available for fish, powershell, and zsh environments.

Environment

The environment requires the Cloud Pak for Security cpctl tool already installed.
Refer to the additional links in this document.

Steps

  1. Enter the following command. Replace <--CP4S-NAMESPACE--> with the namespace Cloud Pak for Security is installed under.
    cpctl load -n <--CP4S-NAMESPACE-->
    For Example:
    cpctl load -n cp4s
  2. Enter the following command. Replace <--SHELL-FILENAME--> with the name of a shell file of your choice.
    cpctl completion bash > <--SHELL-FILENAME-->
    For Example:
    cpctl completion bash > cpctl-complete.sh
  3. OPTION 1: Globally configuring tab auto-completion for all users' client sessions

    If the /etc/bash_completion.d/ directory exists use the following command to copy the auto completion file to it. Replace <--SHELL-FILENAME--> with the name of the newly created shell file.

    sudo cp <--SHELL-FILENAME--> /etc/bash_completion.d/
    For example:
    sudo cp cpctl-complete.sh /etc/bash_completion.d/

    OPTION 2: Locally configuring tab auto-completion for a single user's client session

    Edit the .bashrc file located under the root of the user's home directory and add the following line of text.
    Replace <--SHELL-FILENAME--> with the name of the newly created shell file.

    . $HOME/<--SHELL-FILENAME-->
    For example:
    . $HOME/cpctl-complete.sh
  4. Ensure to start a new terminal session to enable tab auto-completion.
     

Additional Information

If any of the following error messages are encountered by using the cpctl load command, then try the following actions.
  • Error: no pod in default available using label 'run=cp-serviceability'
    ACTION: Issue the command ensuring that the Cloud Pak for Security namespace is specified as shown in the previous example.
     
  • Error: pods is forbidden: User "system:anonymous" cannot list resource "pods" in API group "" in the namespace "default"
    ACTION: Make sure you are logged in to the cluster server command-line interface as an administrator.
     

Document Location

Worldwide

[{"Type":"MASTER","Line of Business":{"code":"LOB24","label":"Security Software"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Product":{"code":"SSTDPP","label":"IBM Cloud Pak for Security"},"ARM Category":[{"code":"a8m0z000000Xat9AAC","label":"Documentation"}],"ARM Case Number":"","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"1.5.0;and future releases"}]

Document Information

Modified date:
21 February 2023

UID

ibm16552214