Enable Autocomplete for the MongoDB CLI

You can enable autocomplete for MongoDB CLI commands to see available commands and their syntax directly in your shell.

If you installed the MongoDB CLI with Homebrew, autocomplete functionality is included with the installation. You must configure your shell to enable its completion support. To enable autocomplete for your shell, refer to the Homebrew Documentation.

Once you have autocomplete configured, you can autocomplete commands by typing mongocli in your shell and pressing the Tab key. Press Tab multiple times to cycle through available autocompletion options.

You can press Tab at any stage of writing your command to see available autocomplete options.

When you type mongocli in your shell and press Tab, the output resembles the following:

atlas -- Atlas operations.
cloud-manager -- Cloud Manager operations.
completion -- Generate shell completion scripts
config -- Configure a profile to store access settings for your MongoDB deployment.
help -- Help about any command
iam -- Organization and projects operations.
ops-manager -- Ops Manager operations.

If you type a specific property such as atlas as part of your command, you can see autocompletion options for your selected property.

For example, when you type mongocli atlas in your shell and press Tab, the output resembles the following:

alerts -- Manage alerts for your project.
backups -- Manage backups for your project.
clusters -- Manage clusters for your project.
dbusers -- Manage database users for your project.
events -- Manage events for your project.
logs -- Download host logs for your project.
metrics -- Get measurements on the state of the MongoDB process.
processes -- Manage MongoDB processes for your project.
whitelist -- Manage the IP whitelist for a project.
Give Feedback