# Enabling Autocomplete for AWS CLI

AWS CLI is the standard way to interact with AWS services using commands in your command-line shell. AWS has over 200 fully-featured services. So, it is almost impossible to remember every CLI command and their parameters. This requires us to refer the  [AWS CLI documentation](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/index.html)  again and again.

The in-built **"Auto-prompt"** feature provided by ***AWS CLI (v2)*** can be easily used to minimise the number of times we refer the CLI documentation.

**Note:** The AWS CLI (v1) does not support this feature. We can easily check the current version of our AWS CLI using the following command:

```bash
aws --version
```

### Auto-prompt in action 🧑‍💻

Just type the partial command that you know, and then click "Enter" to kick-in this feature 👇

![aws-cli-blog.gif](https://cdn.hashnode.com/res/hashnode/image/upload/v1638099949800/SfiXWpP-c.gif)

### Modes of Auto-prompt

Before configuring this, lets talk about the two modes of auto-prompt feature that are provided by AWS CLI:

- **Full mode:** This mode uses the auto-prompt feature each time user runs an AWS command which can be either a complete command or an incomplete command. This can be done manually using the --cli-auto-prompt parameter or can be enabled permanently using the configuration file.
- **Partial mode:** This mode uses the auto-prompt feature if a command is incomplete or cannot be run due to a client-side validation error. This mode is useful in scenarios where you only want to be auto-prompted for commands you are unfamiliar with rather than prompted on every command.

### Recommendation 

Based on my experience, the "Partial mode" for this feature is better than the "Full mode". This helps to avoid any unnecessary prompts if the AWS CLI command you are running is already correct.

### Configuration

The "auto-prompt" feature can be enabled using the following command:

⭐️ **Full mode**

```bash
aws configure set cli_auto_prompt on 
```

⭐️ **Partial mode**

```bash
aws configure set cli_auto_prompt on-partial
```

After using the above commands, this feature is only enabled for the AWS CLI default profile. 

⭐️ **Enabling it for a specific AWS CLI profile**

We can enable this for a specific AWS CLI profile using the --profile parameter i.e.

```bash
aws configure set cli_auto_prompt on-partial --profile <profile-name>
```

And thats it. We are done learning another less known but an useful feature while working with AWS. 

Now you can enjoy this feature and reduce the amount of time you  spend referring to the AWS CLI documentation.

### Reference

[Having the AWS CLI prompt you for commands](https://docs.aws.amazon.com/cli/latest/userguide/cli-usage-parameters-prompting.html)

---

👋 Enjoyed the article? Reach out to me anytime in the comments below or on  [Twitter](https://twitter.com/gurjotsingh4398)  for any further discussion or feedback.
