C Defines for Printing Colors

June 14, 2021 - Reading time: ~1 minute

A header file to define colors to use when printing to the console in C.

#ifndef __COLORS_H_
#define __COLORS_H_
#define _COLOR_CYAN            "\x1b[36m"
#define _COLOR_VIOLET          "\x1b[35m"
#define _COLOR_GREEN           "\x1b[32m"
#define _COLOR_BLUE            "\x1b[34m"
#define _COLOR_YELLOW          "\x1b[33m"
#define _COLOR_RED             "\x1b[31m"
#define _COLOR_LRED            "\x1b[1;31m"
#define _COLOR_YELLOWONRED     "\x1b[1;33;41m"
#define _COLOR_UYELLOWONRED    "\x1b[1;4;5;33;41m"
#define _COLOR_RESET           "\x1b[0m"
#define _COLOR_OUTPUT          _COLOR_CYAN
#define _COLOR_DEBUG           _COLOR_VIOLET
#define _COLOR_INFO            _COLOR_GREEN
#define _COLOR_NOTICE          _COLOR_BLUE
#define _COLOR_WARNING         _COLOR_YELLOW
#define _COLOR_ERROR           _COLOR_RED
#define _COLOR_CRITICAL        _COLOR_LRED
#define _COLOR_ALERT           _COLOR_YELLOWONRED
#define _COLOR_EMERGENCY       _COLOR_UYELLOWONRED
#endif

Add Some Color to Man Pages

June 14, 2021 - Reading time: ~1 minute

I was looking through my .bashrc and came across this. I've been using it so long that I had forgotten that colorized Man pages aren't usually the default. I can't remember where I found it.

Add some color to your man pages.

    man() {
    LESS_TERMCAP_md=$'\e[01;31m' \
    LESS_TERMCAP_me=$'\e[0m' \
    LESS_TERMCAP_us=$'\e[01;32m' \
    LESS_TERMCAP_ue=$'\e[0m' \
    LESS_TERMCAP_so=$'\e[45;93m' \
    LESS_TERMCAP_se=$'\e[0m' \
    command man "$@"
    }

Categories