Skip to content

Instantly share code, notes, and snippets.

@sawanoboly
Created November 14, 2011 09:41
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save sawanoboly/1363618 to your computer and use it in GitHub Desktop.
Save sawanoboly/1363618 to your computer and use it in GitHub Desktop.
Sample .mongorc.js for replicaSets.
prompt = function() {
// set version
version = db.version();
// 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 + '] > ';
}
@sawanoboly
Copy link
Author

put this script to ~/.mongorc.js

@ajduke
Copy link

ajduke commented Jul 1, 2013

I forked to include the current database name : https://gist.github.com/5898857.git

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment