Is there a way to tell Mongo to pretty print output? Currently, everything is output to a single line and it's difficult to read, especially with nested arrays and documents.mongodbcommand-line-interfacemongo-shell
(note: this is answer to original version of the question, which did not have requirements for "default")
You can ask it to be pretty.
You can add
DBQuery.prototype._prettyShell = true
to your file in
$HOME/.mongorc.js to enable pretty print globally by default.
However, this will print all the documents of the collection unlike
pretty() that will allow you to iterate.
Oh so i guess .pretty() is equal to:
(note: this is answer to the updated question)
You can just do this on the CLI:
echo DBQuery.prototype._prettyShell = true >> ~/.mongorc.js
And it's always going to output pretty results.
Give a try to Mongo-hacker(node module), it alway prints pretty. https://github.com/TylerBrock/mongo-hacker
More it enhances mongo shell (supports only ver>2.4, current ver is 3.0), like
I am using for while in production env, no problems yet.