console-colors 1.0.1

If it's worth having a command-line, then it's worth having colors.

To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:



console-colors is an attempt towards making the ultimate zero-hassle console color library for D.

It is meant as a spiritual successor of the colorize package and try to improve it based upon industrial usage of console colors in very important software.

As it is a very competitive field, we'll try to establish some claims using reasoning that this thing is better than some other related things.


import std.stdio;
import consolecolors;

void main(string[] args)
        // do stuff that can throw
    catch(CCLException e) // An exception with a coloured message
        cwritefln("<lred>Error:</lred> %s", e.msg)
    catch(Exception e) // An uncoloured exception.
        cwritefln("<lred>Error:</lred> %s", escapeCCL(e.msg));


  • Use 16 different colors in the terminal, for foreground and background.

  • Escape and un-escape from Console Colors Language (CCL), in order to mix and match coloured and uncoloured exceptions in your codebase. Now you can `throw` with color information.

  • One file, can be copied in your project.

  • Color information can be given in two ways:

  • Within text with easy-to-remember tags, such as "my <blue> text is <red>coloured</red></blue>" Syntax errors within these tags throw, for the moment.

  • with string helper UFCS functions, such as "my" ~ ("text is " ~ "coloured".red).blue

  • Portable with a special cwrite[f][ln] call, like the colorize package. Indeed, color information need to be inline within text, to properly nest in format strings. console-colors has a color stack to restore the previously set color.

  • All colors have an easy shortcut like .lmagenta or .white, making it easier to add color in the first place (at the cost of your namespace).

  • Colors can be disabled globally, with disableConsoleColors(). It is an often wanted thing in command-line tools with colors. Colors are also disabled if stdout isn't a terminal, or if the terminal initialization failed.

We are heading towards the ultimate console in D. Reaching for the stars here. You have no excuse anymore not to have colors in your terminal.

If it's worth having a command-line, then it's worth having colours. - Adam Smith, Wealth of Nations

1.3.1 2024-Feb-24
1.3.0 2024-Feb-23
1.2.0 2023-Dec-27
1.1.2 2023-Dec-26
1.1.1 2023-May-20
Show all 16 versions
Download Stats:
  • 9 downloads today

  • 122 downloads this week

  • 444 downloads this month

  • 20503 downloads total

Short URL: