Configure Settings Using a Configuration File
On this page
You can specify mongosh
settings in a global configuration file.
When you specify settings in a configuration file, those settings are
applied at startup. After you create a configuration file, the settings
in the file take effect the next time you start mongosh
.
Configuration File Format
The mongosh
configuration file uses the YAML format. All options are
under the mongosh
namespace.
Example Configuration File
The following configuration file sets:
displayBatchSize
to 50inspectDepth
to 20redactHistory
toremove-redact
mongosh: displayBatchSize: 50 inspectDepth: 20 redactHistory: "remove-redact"
Configuration File Location
The file location where mongosh
looks for the configuration file
depends on your operating system:
Operating System | File Location |
---|---|
Windows |
|
macOS |
Once |
Linux |
|
Configurable Settings
You can specify the following mongosh
settings in your configuration
file:
Key | Type | Default | Description |
---|---|---|---|
| integer | 20 | The number of items displayed per cursor iteration |
| boolean |
| Enables sending anonymized tracking and diagnostic data to MongoDB. |
| string |
| Designates an editor to use within the |
| boolean |
| Only available in the global configuration file. When true, users cannot enable telemetry manually. |
| integer | 1000 | The number of items to store in |
| integer or boolean | 3 | |
| integer or Infinity | 6 | The depth to which objects are printed. Setting |
| string |
| Controls what information is recorded in the shell history. Must be one of:
|
| boolean |
| Controls display of a stack trace along with error messages. |
| boolean |
| If |
| string | A semicolon-separated list of URLs that link to a snippet registry. | |
| string |
Behavior with config
API
Settings specified with the config API:
Override settings specified in the configuration file.
Persist across restarts.
Example
Consider the following configuration file that sets the
inspectDepth
setting to 20
:
mongosh: inspectDepth: 20
During your mongosh
session you run the following command to set
inspectDepth
to 10
:
config.set( "inspectDepth", 10 )
The value of inspectDepth
becomes 10
, and will remain 10
even when mongosh
is restarted.