Skip to content

Instantly share code, notes, and snippets.

@PanayotCankov
Created January 16, 2017 14:55
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 PanayotCankov/64f55d2e643ec1bf2369a1127f594234 to your computer and use it in GitHub Desktop.
Save PanayotCankov/64f55d2e643ec1bf2369a1127f594234 to your computer and use it in GitHub Desktop.
Nice undetermined activity indicator and a progress bar for the terminal
var chars = "○○◐●◕◑◔";
var progress_chars = " ▏▎▍▌▋▊▉█";
var p = 0;
var progLen = 8;
function progress() {
p = 1 + (p % (8 * progLen));
var r = "";
for (var i = 0; i < progLen; i++) {
r += progress_chars[Math.max(0, Math.min(8, p - i * 8))];
}
return r + "▏";
}
console.log(" ✔ less");
console.log(" ✘ sass");
var i = 0;
setInterval(() => {
process.stdout.write("\r " + chars[i = (i + 1) % chars.length] + " " + progress() + "tsc ");
}, 175);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment