Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

README.md

Color

source color.sh

echo "This is ${pred}RED$preset."
echo "This is $(c IndianRed)Indian Red$preset."

Using

  1. Define c_truecolor to true or false. There is not (yet) any automatic detection to distinguish 8-bit (256) color terminals from 24-bit (16 million)1. The Mac OS X system terminal lags behind most others in this respect2. The default is true.
  2. Optionally set X11_RGB_TXT to the full path of your rgb.txt such as provided with X11. If unset, defaults to /usr/share/X11/rgb.txt, or if that file is unreadable, to an rgb.txt provided with colors.sh.
  3. Source color.sh.
printf "\x1b[38;2;255;100;0mTRUECOLOR\x1b[0m\n"

Please note the default MacOS terminal is anemic, and does not show colors as nicely as Linux or Windows.

Pre-defined variables

echo "This is $pbold${pred}bold red$preset."
echo "This is $pitalic${pgreen}italic green$preset."

All predefined variables are prefixed with p, as in $pred or ${preset}.

Reset

To restore default text properties:

  • reset

Colors

The basic ANSI 8 colors as foreground:

  • black
  • red
  • green
  • yellow
  • blue
  • magenta
  • cyan
  • white

Effects

The most supported ANSI text effects:

  • bold
  • light
  • italic
  • underscore
  • blink
  • reverse
  • invisible
  • strikethrough

X11 colors

cat <<EOM
Reds include:
* $(c IndianRed)Indian red$preset
* $(c OrangeRed)orange red$preset
* $(c VioletRed)violet red$preset
* $(c DarkRed)dark red$preset
EOM
echo "Or you can make $(c 210 30 30)your own red$preset."

Using an 24-bit color palette, and to a lesser degree 8-bit, you can use around 500 X11-defined colors by name, or provide your own RGB values.

Reading

TODO

Footnotes

  1. I need to investigate test if your terminal supports 24 bit true color. This formula may work, but needs testing, and integration into color.sh:

  2. Since I last wrote this, it seems improved on MacOS.