Changing console output color
October 22, 2011 § 1 Comment

Recently I have been learning git and have was intrigued with their use of color in the console output. (You also experience this when you run msbuild). Anyway it turns out this is actually really easy to do in your own console applications. Here is the code that produces the output you see in the image.
static void Main(string[] args)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Red");
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("Yellow");
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Green");
Console.ResetColor();
Console.WriteLine("Normal");
Console.ReadLine();
}
Very awesome. I have never looked into much in the way of customization on the Windows CLi before, outside of changing the default font. There are lots of things you can do with colors with Bash also…almost too much, actually.