Skip to content

Instantly share code, notes, and snippets.

@ajduke
Forked from sawanoboly/.mongorc.js
Last active December 19, 2015 04:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ajduke/5898857 to your computer and use it in GitHub Desktop.
Save ajduke/5898857 to your computer and use it in GitHub Desktop.
including the which is current database
prompt = function() {
// set version
version = db.version();
dbName = db.getName()
// case mongos
if (rs.status().info == 'mongos') {
return rs.status().info + ':[' + version + '] > ';
}
// config or replica
if (rs.status().set) {
role = rs.status().set;
} else {
role = 'config';
return role + ':[' + version + '] > ';
}
// for replicasets
switch (rs.status().myState) {
case 1:
stateStr = 'PRIMARY';
break;
case 2:
stateStr = 'SECONDARY';
break;
case 7:
stateStr = 'ARBITER';
break;
}
return role + ':' + stateStr + ':[' + version + ']'+':' + dbName +'> '';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment