task-color (5) - Linux Manuals
task-color: A color tutorial for the Taskwarrior command line todo manager.
NAME
task-color - A color tutorial for the Taskwarrior command line todo manager.
SETUP
The first thing you need is a terminal program that supports color. All terminal programs support color, but only a few support lots of colors. First tell your terminal program to use color by specifying the TERM environment variable like this:
In this example, xterm-color is used - a common value, and one that doesn't
require that you use xterm. This works for most setups. This setting belongs
in your shell profile (~/.bash_profile, ~/.bashrc, ~/.cshrc etc, depending on
which shell you use). If this is a new setting, you will need to either run
that profile script, or close and reopen the terminal window (which does the
same thing).
Now tell Taskwarrior that you want to use color. This is the default for
Taskwarrior, so the following step may be unnecessary.
This command will make sure there is an entry in your ~/.taskrc file that looks
like:
Now Taskwarrior is ready.
Do we really want all those color control codes in the file? Taskwarrior
assumes that you do not, and temporarily sets color to 'off' while generating
the output. This explains the output from the following command:
it always returns 'off', no matter what the setting, because the output is being
sent to a pipe.
If you wanted those color codes, you can override this behavior by setting the
_forcecolor variable to on, like this:
or by temporarily overriding it like this:
The output cannot be replicated here in a man page, but you should see a set of
color samples. How many you see depends on your terminal program's ability to
render them.
You should at least see the Basic colors and Effects - if you do, then you have
16-color support. If your terminal supports 256 colors, you'll know it!
Foreground color (for text) is simply specified as one of the above colors, or
not specified at all to use the default terminal text color.
Background color is specified by using the word 'on', and one of the above
colors. Some examples:
These colors can be modified further, by making the foreground bold, or by
making the background bright. Some examples:
The order of the words is not important, so the following are equivalent:
But the 'on' is important - colors before the 'on' are foreground, and colors
after 'on' are background.
There is an additional 'underline' attribute that may be used:
And an 'inverse' attribute:
Taskwarrior has a command that helps you visualize these color combinations.
Try this:
You can use this command to see how the various color combinations work. You
will also see some sample colors displayed, like the ones above, in addition to
the sample requested.
Some combinations look very nice, some look terrible. Different terminal
programs do implement slightly different versions of 'red', for example, so you
may see some unexpected variation across machines. The brightness of your
display is also a factor.
Using 256 colors follows the same form, but the names are different, and some
colors can be referenced in different ways. First there is by color ordinal,
which is like this:
This gives you access to all 256 colors, but doesn't help you much. This range
is a combination of 8 basic colors (color0 - color7), then 8 brighter variations
(color8 - color15). Then a block of 216 colors (color16 - color231). Then a
block of 24 gray colors (color232 - color255).
The large block of 216 colors (6x6x6 = 216) represents a color cube, which can
be addressed via RGB values from 0 to 5 for each component color. A value of 0
means none of this component color, and a value of 5 means the most intense
component color. For example, a bright red is specified as:
And a darker red would be:
Note that the three digits represent the three component values, so in this
example the 5, 0 and 0 represent red=5, green=0, blue=0. Combining intense red
with no green and no blue yields red. Similarly, blue and green are:
Another example - bright yellow - is a mix of bright red and bright green, but
no blue component, so bright yellow is addressed as:
A soft pink would be addressed as:
See if you agree, by running:
You may notice that the large color block is represented as 6 squares. All
colors in the first square have a red value of 0. All colors in the 6th square
have a red value of 5. Within each square, blue ranges from 0 to 5 left to
right, and within each square green ranges from 0 to 5, top to bottom. This
scheme takes some getting used to.
The block of 24 gray colors can also be accessed as gray0 - gray23, in a
continuous ramp from black to white.
If you specify 16-colors, and view on a 256-color terminal, no problem. If you
try the reverse, specifying 256-colors and viewing on a 16-color terminal, you
will be disappointed, perhaps even appalled.
There is some limited color mapping - for example, if you were to specify this
combination:
you are mixing a 16-color and 256-color specification. Taskwarrior will map red
to color1, and proceed. Note that red and color1 are not quite the same tone.
Note also that there is no bold or bright attributes when dealing with 256
colors, but there is still underline available.
This gives you an example of each of the colors, so you can see the effect,
without necessarily creating a set of tasks that meet each of the rule criteria.
AUTOMATIC MONOCHROME
It should be mentioned that Taskwarrior is aware of whether its output is going
to a terminal, or to a file or through a pipe. When Taskwarrior output goes to
a terminal, color is desirable, but consider the following command:
AVAILABLE COLORS
Taskwarrior has a 'color' command that will show all the colors it is capable of
displaying. Try this:
16-COLOR SUPPORT
The basic color support is provided through named colors:
256-COLOR SUPPORT
MIXING 16- AND 256-COLORS
LEGEND
Taskwarrior will show examples of all defined colors used in your .taskrc, or
theme, if you run this command:
RULES
Taskwarrior supports colorization rules. These are configuration values that
specify a color, and the conditions under which that color is used. By example,
let us add a few tasks: