MongoDB Documentation, Release 3.0.4 Set prompt to any string or arbitrary JavaScript code that returns a string, consider the following examples: • Set the shell prompt to display the hostname and the database issued: • Set the shell prompt to display the database statistics: var host = db.serverStatus().host; var prompt = function () { return db+"@"+host+"> "; } The mongo shell prompt should now reflect the new prompt: test@my-machine.local> var prompt = function () { return "Uptime:"+db.serverStatus().uptime+" Documents:"+ db.stats().objects } The mongo shell prompt should now reflect the new prompt: Uptime:1052 Documents:25024787 > You can add the logic for the prompt in the .mongorc.js file to set the prompt each time you start up the mongo shell. 11.3.5 Can I edit long shell operations with an external text editor? You can use your own editor in the mongo shell by setting the EDITOR environment variable before starting the mongo shell. Once in the mongo shell, you can edit with the specified editor by typing edit <variable> or edit <function> , as in the following example: The command should open the vim edit session. Remember to save your changes. The result should be the changes from your saved edit: 11.3. FAQ: The mongo Shell 757 1. Set the EDITOR variable from the command line prompt: 2. Start the mongo shell: 3. Define a function myFunction : 4. Edit the function using your editor: 5. Type myFunction to see the function definition: EDITOR=vim mongo function myFunction () { } edit myFunction myFunction function myFunction() { print("This was edited"); }