Created
June 27, 2019 00:17
-
-
Save jeffjohnson9046/31cfcd01b768c365587bac86f86e3a90 to your computer and use it in GitHub Desktop.
A prompt for the mongo shell that displays the user you're logged in as and the database you're pointed at.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
Set the mongo shell prompt to display [user name]@[database name]. If the user or database name cannot | |
be captured, then display "<none>" instead. | |
*/ | |
var prompt = function() { | |
var user = db.runCommand({connectionStatus : 1}).authInfo.authenticatedUsers[0].user || "<none>"; | |
var dbLabel = db.getName() || "<none>"; | |
return user + "@" + dbLabel + ">"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment