Skip to content

Instantly share code, notes, and snippets.

@tmaeda1981jp
Last active December 30, 2015 09:19
Show Gist options
  • Save tmaeda1981jp/7808072 to your computer and use it in GitHub Desktop.
Save tmaeda1981jp/7808072 to your computer and use it in GitHub Desktop.
text progress bar example
String.prototype.repeat = function(num) {
return new Array(num + 1).join(this);
};
var sprintf = require('sprintf'),
util = require('util'),
colors = require('colors'),
total = 10000,
i;
console.log("This could take a while. You can run the following command on another shell to track the status:\n".green);
console.log(" tail -f ./path/to/output\n".yellow);
for (i=1; i<=total; i+=1) {
util.print('\r' + sprintf('[ %-100s ] %d / %d', '#'.repeat(Math.floor(i/total*100)), i, total));
}
console.log("\n\nFinished!\n".green);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment