I don't seem to be able to find any examples on the Internet for this environment variable, which top will apparently read and use to display colours.

How would I set this variable correctly so top used alternate colours in its output?

I have Solaris top version 3.5beta9.


The TOPCOLORS variable in this top (also referred to as unixtop) is not available in the version you are using. It first appeared in version 3.6 of this utility, as stated in the COLOR section of the README file. For some reason, it seems that the usual BSD don't include an updated version of top (FreeBSD 9.1 has 3.5beta12).

If you can install or compile an updated version, the man page should give you more information on how to set colours. In version 3.8beta1 that is what it prints:


Specifies colors to use and conditions for which they should be used. At the present time, only numbers in the summary display area can be colored. In a future version it will be possible to highlight numbers in the process display area as well. The environment variable is the only way to specify color: there is no equivalent command line option. Note that the environment variable TOPCOLOURS is also understood. The British spelling takes precedence. The use of color only works on terminals that understand and process ANSI color escape sequences.

The environment variable is a sequence of color specifications, separated by colons. Each specification takes the form tag=min,max#code where

  • tag is the name of the value to check,
  • min and max specify a range for the value, and
  • code is an ANSI color code.

Multiple color codes can be listed and separated with semi-colons. A missing min implies the lowest possible value (usually 0) and a missing max implies infinity. The comma must always be present.

When specifying numbers for load averages, they should be multiplied by 100. For example, the specification:

  • 1min=500,1000#31 indicates that a 1 minute load average between 5 and 10 should be displayed in red.

Color attributes can be combined. For example, the specification:

  • 5min=1000,#37;41 indicates that a 5 minute load average higher than 10 should be displayed with white characters on a red background.

A special tag named header is used to control the color of the header for process display. It should be specified with no lower and upper limits, specifically header=,# followed by the ANSI color code.

You can see a list of color codes recognized by this installation of top with the -T option. This will also show the current set of tests used for color highligting, as specified in the environment.

(end of man page extract)

Colour Codes

The color.h file from the source code list the tags and codes the utility understands. The tags are:

 * These color tag names are currently in use
 * (or reserved for future use):
 * cpu, size, res, time, 1min, 5min, 15min, host

And the color are the ANSI ones:

 * Valid ANSI values for colors are:
 * 0    Reset all attributes
 * 1    Bright
 * 2    Dim
 * 4    Underscore  
 * 5    Blink
 * 7    Reverse
 * 8    Hidden
 *  Foreground Colours
 * 30   Black
 * 31   Red
 * 32   Green
 * 33   Yellow
 * 34   Blue
 * 35   Magenta
 * 36   Cyan
 * 37   White
 *  Background Colours
 * 40   Black
 * 41   Red
 * 42   Green
 * 43   Yellow
 * 44   Blue
 * 45   Magenta
 * 46   Cyan
 * 47   White


Using the following setup, you can get a glimpse at the possibilities (here for top 3.8beta1 compiled on FreeBSD):

export TOPCOLORS="header=,#1\

A call to top -T will directly show you if top understands the color setup you've declared. It will also list all the tags understood (which in my case where somewhat different from the content of the color.h file).


On different UNIX systems, alternatives are used. Under Linux you usually find the top utility coming from the procps package. You can also install htop which is a nice colourful alternative that is also available on OSX and FreeBSD (where it relies on the Linux layer), but AFAIK not on Solaris.

  • Very nice answer. – jasonwryan Dec 9 '13 at 19:55
  • Thanks for the in-depth answer and pertinant info that it is not supported in that version. However, you have not actually given a complete example of a working TOPCOLORS value. Imagine for a minute that a busy person hasn't got time to read this particular manual and wants simply to try out a couple of ready-made examples. – Captain Lepton Dec 10 '13 at 10:24
  • To be complete, I have added a TOPCOLORS working example. – Læti Dec 21 '13 at 13:26
  • Heh just noticed this, thanks again for your help – Captain Lepton Dec 8 '16 at 15:57

Not exactly what you're looking for, but I found this .toprc that works with version 3.3.9 and later, which sets custom colors somewhere in there:


RCfile for "top with windows"           
Id:a, Mode_altscr=0, Mode_irixps=1, Delay_time=3.000, Curwin=0
Def     fieldscur=AEHIOQTWKNMbcdfgjplrsuvyzX
        winflags=63800, sortindx=10, maxtasks=0
        summclr=2, msgsclr=1, headclr=3, taskclr=1
Job     fieldscur=ABcefgjlrstuvyzMKNHIWOPQDX
        winflags=62777, sortindx=0, maxtasks=0
        summclr=6, msgsclr=6, headclr=7, taskclr=6
Mem     fieldscur=ANOPQRSTUVbcdefgjlmyzWHIKX
        winflags=62777, sortindx=13, maxtasks=0
        summclr=5, msgsclr=5, headclr=4, taskclr=5
Usr     fieldscur=ABDECGfhijlopqrstuvyzMKNWX
        winflags=62777, sortindx=4, maxtasks=0
        summclr=3, msgsclr=3, headclr=2, taskclr=3

Awesome example above. I tried something much simpler (albeit a little more attractive) on FreeBSD 10.1. I needed to install top 3.8 from source. The following works fomr csh/tcsh

    setenv TOPCOLORS "header=,#35;1:1min=,#31;1:5min=,#31;1:15min=,#31;1:cpu.user=,#32:cpu.system=,#32:cpu.nice=,#32:cpu.interrupt=,#32:cpu.idle=,#32:memory.wired=,#36:memory.active=,#36:memory.inact=,#36:memory.cache=,#36:memory.buf=,#36:memory.free=,#36:kernel.ctxsw=,#33:kernel.trap=,#33:kernel.intr=,#33:kernel.soft=,#33:kernel.fork=,#33:kernel.flt=,#33:kernel.pgin=,#33:kernel.pgout=,#33:kernel.fr=,#33:swap.total=,#34;1:swap.used=,#34;1:swap.free=,#34;1:swap.inuse=,#34;1:swap.in=,#34;1:swap.out=,#34;1"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.