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 execute partially typed commands and produces command-related prompts. This function is not installed automatically. You need to 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 login.
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 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
After the command is entered, check whether the input is correct. Enter complete, and check whether the above information is filled.
If the following information is displayed, it indicates that the input is correct.
complete -C <path of aliyun_completer, like /usr/local/bin/aliyun_completer > aliyuncli
To ensure that command auto-completion is enabled every time when you launch bash, you need to 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.