Pretty print in MongoDB shell as default
Pretty print in MongoDB shell as default
(Notice:The following answer should be a original version of the question, which did not have requirements for “default”)
The below code will be usefull:
db.collection.find().pretty()
Just you can try to add:
DBQuery.prototype._prettyShell = true
Here to your file in $HOME/.mongorc.js to enable pretty print globally by default
(Notice: For the following answer to the updated question)
Just can you do this on the CLI
echo DBQuery.prototype._prettyShell = true >> ~/.mongorc.js
It always provide pretty results