Skip to content

Instantly share code, notes, and snippets.

@AhmadTawila
Created June 11, 2019 09:12
Show Gist options
  • Save AhmadTawila/b84fefe35cd476d4aa7207d2e79b0c69 to your computer and use it in GitHub Desktop.
Save AhmadTawila/b84fefe35cd476d4aa7207d2e79b0c69 to your computer and use it in GitHub Desktop.
# http://jerwinroy.blogspot.com/2015/04/view-current-userhostport-and-database.html
prompt = function() {
user = db.runCommand({connectionStatus:1}).authInfo.authenticatedUsers[0]
host = db.getMongo().toString().split(" ")[2]
curDB = db.getName()
if (user) {
uname = user.user
}
else {
uname = "local"
}
return uname + "@" + host + ":" + curDB + "> "
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment