Skip to content

Instantly share code, notes, and snippets.

@prettydiff
Last active March 18, 2018 11:50
Show Gist options
  • Save prettydiff/8682c3a4bbaadd1a0fe0103f1ad65c98 to your computer and use it in GitHub Desktop.
Save prettydiff/8682c3a4bbaadd1a0fe0103f1ad65c98 to your computer and use it in GitHub Desktop.
color cycle text for the commandline
function changeColor(str) {
const arr = str.split("");
let a = arr.length - 1,
b = 8;
do {
arr[a] = `\u001b[3${b}m${arr[a]}`;
a = a - 1;
b = b - 1;
if (b < 1) {
b = 8;
}
} while (a > 0);
return arr.join("") + "\u001b[0m";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment