Skip to content

Instantly share code, notes, and snippets.

@pfeilbr
Last active August 31, 2016 14:28
Show Gist options
  • Save pfeilbr/ef5fb70f2c3a45f6e71370e3d000b8ed to your computer and use it in GitHub Desktop.
Save pfeilbr/ef5fb70f2c3a45f6e71370e3d000b8ed to your computer and use it in GitHub Desktop.
// Text color codes:
// 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white
// see: http://webhome.csc.uvic.ca/~sae/seng265/fall04/tips/s265s047-tips/bash-using-colors.html
// '\u001b' is ESC (escape)
function color(s, c) {
return '\u001b[' + c + ';1m' + s + '\u001b[0m';
}
const s = `Hello ${color('World', 32)}. How are you?`
console.log(s)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment