On some systems, NetHack can display monsters, objects and dungeon features in color. (This is not the same thing as the graphical display using tiles.) The exact appearance of these colors depends on many things, including the platform NetHack was compiled for, compile-time options, run-time options, your terminal settings and the monitor you're using.
If your NetHack supports color output, it can be toggled on or off using the color option.
NetHack color codes
Internally, the colors in NetHack are specified using the 16 CLR_* color codes (including NO_COLOR, a dark gray used as the default color) defined in the file includes/color.h.
|color name||numeric value|
The same file also defines a number of "logical" colors for different materials and effects which map to these 16 colors: for example, both leather and wood are defined to be CLR_BROWN.
|logical name||color name|
Terminal color codes
On systems where NetHack outputs text to be displayed in a terminal (rather than handling text rendering by itself), the internal color codes defined in color.h are mapped to ANSI escape codes or equivalent codes defined in the system terminfo. This mapping is specified in win/tty/termcap.c, and (for a mapping of 16 to 16 colors) is surprisingly platform-dependent. Notable quirks include:
- On systems defining MICRO (which are these?), CLR_BLUE is mapped to the same color code as CLR_BRIGHT_BLUE, presumably because the default blue is considered too dark.
- On many (most?) systems (which?), no color codes are defined for CLR_BLACK, CLR_GRAY and NO_COLOR, leaving them all as the default text color (usually gray).
- On Unix systems using terminfo, CLR_BLACK is actually aliased to CLR_BLUE. There is a comment saying that this is done to avoid trying to display black text on a (presumed) black background, as it might not be visible.
- On the Atari TOS port, several of the darker colors are mapped to their bright counterparts. (Which ones? The code is kind of confusing...)
On some systems, the mapping from NetHack colors to terminal colors may be adjusted using the videocolors option.
On some systems, NetHack directly maps the 16 internal color codes to RGB colors. On others, this task is left for the terminal emulator, while on some (mainly older) systems, the color choices may even be determined by the graphics hardware.
A user has suggested improving this page or section as follows:
"List some NetHack/terminal color palettes here."
- Bright green
- Bright blue
- Bright magenta
- Bright cyan
Even the appearance of the RGB colors is not fixed, but can vary depending on your display hardware and software. Some issues that can affect color rendering include:
- Your computer may or may not apply gamma correction to colors (and, if it does, it may or may not be properly calibrated). Also, different monitors may have different natural gamma values, and on some monitors the gamma value may even be adjustable.
- CRT and LCD monitors have different color gamuts, affecting the colors they can display.
- The brightness, contrast and color temperature of the monitor can also vary, and are often subject to user adjustment.
- Finally, ambient lighting and variations in the human eye itself can affect the appearance of colors.
What all this comes down to is that colors which look nice and easily visible to one person may not look as good to another. Thus, picking a good color palette is ultimately a personal, subjective choice.
Changing terminal colors
From the command line: rxvt -color4 lightblue.
rxvt colors can also be set via the X11 resources as seen in the xterm configuration below by using Rxvt*color4: lightblue in ~/.Xdefaults
From the command line: xterm -xrm "XTerm*color4: lightblue"
Similar to setting X11 resources, you can change the colors used by xterm, by putting eg. the following in ~/.Xdefaults:
And then doing xrdb -merge ~/.Xdefaults to set the resource. Starting xterm after that will use the lightblue color.
You can output an OSC control sequence to change a color. The format is: Esc]Pnrrggbb, where Esc means the escape character. nrrggbb is a sequence of 7 hexadecimal digits, where n is the color number, and rr, gg and bb are the red, green and blue parts of the color.
You can do this with the echo command, for example:
echo -e '\e]P40000ff'
This will set the fourth color (dark blue) to the RGB values 0, 0, and 255. To reset all colors, use this sequence:
echo -e '\e]R'
You might want to put this into a script so you don't have to do this manually every time you play.