Skip to content

Instantly share code, notes, and snippets.

@NattyNarwhal
Created May 6, 2016 12:51
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 NattyNarwhal/93764669ded3851e7a691f1304e29fc9 to your computer and use it in GitHub Desktop.
Save NattyNarwhal/93764669ded3851e7a691f1304e29fc9 to your computer and use it in GitHub Desktop.
const char esc = (char)0x1b;
// not all terms support this; in case not, a muxer like tmux or screen will approximate it
public string TrueColorEscaped(string obj, int r, int g, int b) {
// <ESC>[38;2;{r};{g};{b}m sets a true color color
// <ESC>[0m resets color
return String.Format("{0}[38;2;{1};{2};{3}m{4}{0}[0m", esc, r, g, b, obj);
}
foreach (var i in Enumerable.Range(0, 255))
Console.WriteLine(TrueColorEscaped("Hello world", i, 0, 0));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment