MongoDB Documentation, Release 3.0.4 host = db.serverStatus().host; prompt = function () { return db+"@"+host+"$ "; } <database>@<hostname>$ use records switched to db records records@<hostname>$ prompt = function () { return "Uptime:"+db.serverStatus().uptime+" Documents:"+db.stats().objects+" > "; } MongoDB shell version: 2.2.0 > function f() {} > edit f > f function f() { print("this really works"); } > f() this really works > o = {} { } > edit o > o { "soDoes" : "this" } > Then, consider the following example shell session: export EDITOR=vim mongo At your system prompt you can define the EDITOR variable and start mongo with the following two operations: Note: As mongo shell interprets code edited in an external editor, it may modify code in functions, depending on 275 5.2. Administration Tutorials In the mongo shell you can use the edit operation to edit a function or variable in an external editor. The edit operation uses the value of your environments EDITOR variable. New in version 2.2. Uptime:5897 Documents:6 > db.people.save({name : "James"}); Uptime:5948 Documents:7 > The prompt would then resemble the following: To create a mongo shell prompt that contains the system up time and the number of documents in the current database, define the following prompt variable: Example Use an External Editor in the mongo Shell The prompt would then resemble the following: