Last active
August 14, 2021 06:01
-
-
Save hebertluiz/6208ced4db92db06eb0e699b62aaa5eb to your computer and use it in GitHub Desktop.
tput terminfo basic color reference
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set_color () { | |
local arg2 | |
case $2 in | |
bg|background) | |
arg2=setb | |
;; | |
*) | |
arg2=setf | |
esac | |
case $1 in | |
black|BLACK) | |
$(tput $arg2 0) | |
;; | |
blue|BLUE) | |
$(tput $arg2 1) | |
;; | |
green|GREEN) | |
$(tput $arg2 2) | |
;; | |
cyan|CYAN) | |
$(tput $arg2 3) | |
;; | |
red|RED) | |
$(tput $arg2 4) | |
;; | |
magenta|MAGENTA|magen) | |
$(tput $arg2 5) | |
;; | |
yellow|YELLOW|yellw) | |
$(tput $arg2 6) | |
;; | |
white|WHITE) | |
$(tput $arg2 7) | |
;; | |
*) | |
$(tput sgr0) | |
;; | |
esac | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The setaf/setab and setf/setb capabilities take a single numeric argument each. | |
Argument values 0-7 of setaf/setab are portably defined as follows (the middle column is the symbolic #define available in the header for the curses or ncurses libraries). The terminal hardware is free to map these as it likes, but the RGB values indicate normal locations in color space. | |
Color #define Value RGB | |
black COLOR_BLACK 0 0, 0, 0 | |
red COLOR_RED 1 max,0,0 | |
green COLOR_GREEN 2 0,max,0 | |
yellow COLOR_YELLOW 3 max,max,0 | |
blue COLOR_BLUE 4 0,0,max | |
magenta COLOR_MAGENTA 5 max,0,max | |
cyan COLOR_CYAN 6 0,max,max | |
white COLOR_WHITE 7 max,max,max | |
The argument values of setf/setb historically correspond to a different mapping, i.e., | |
Color #define Value RGB | |
black COLOR_BLACK 0 0, 0, 0 | |
blue COLOR_BLUE 1 0,0,max | |
green COLOR_GREEN 2 0,max,0 | |
cyan COLOR_CYAN 3 0,max,max | |
red COLOR_RED 4 max,0,0 | |
magenta COLOR_MAGENTA 5 max,0,max | |
yellow COLOR_YELLOW 6 max,max,0 | |
white COLOR_WHITE 7 max,max,max | |
It is important to not confuse the two sets of color capabilities; otherwise red/blue will be interchanged on the display. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment