On Linux/UNIX and Mac OS systems, Alibaba Cloud CLI includes a command prompt and auto-completion function. This enables you to use the Tab key to run partially typed commands and produces command-related prompts. This function is not installed automatically. You must configure it manually.
The following information is required to complete the configuration:
The name of your Shell in use.
The path of alicloud_completer script.
If you do not know your Shell in use, you can identify it using one of the following commands. Currently, automatic completion of bash and Zsh is supported.
Method 1: Display the installation directory of Shell
Run the following command to display the installation directory of Shell. This usually matches your Shell in use unless you start another Shell after logon.
Method 2: Display the running processes of the current user
Run the following command to display the running processes of the current user. Among them, you can find Shell.
Run the following command to find the path aliyun_completer.
Shell type – bash
Run the following command to enable command auto-completion by using the internal command complete.
The complete command is a bash auto-completion command. It adds the specified completion script to the executable file, so that a prompt is displayed and the automatic completion is enabled upon pressing Tab.
complete -C '<path of aliyun_completer, like /usr/local/bin/aliyun_completer>' aliyuncli
Run the following command to check whether the auto-completion feature has been enabled.
If the following information is displayed, it indicates that the auto-completion feature has been enabled.
complete -C <path of aliyun_completer, like /usr/local/bin/aliyun_completer > aliyuncli
To make sure that command auto-completion is enabled every time when you launch bash, you must add the auto-completion command to the Shell configuration file.
Run the following command to add the command in Step 1 to the file named.bash_profile.
Add complete -C '<path of aliyun_completer, like /usr/local/bin/aliyun_completer>' aliyuncli to the end of file.
Shell type – zsh
Run the following command to use alicloud_zsh_complete.sh to implement automatic completion.