libColors
Functions to help with color.
Overview
Functions to help with color.
Contains the following:
ksl::isColorCapable()
ksl::enableColor()
ksl::disableColor()
ksl::useColor()
Sourcing libColors.bash implicitly calls ksl::enableColor() and
if the terminal is capable of color, KSL_USE_COLOR is set to true.
So an application does not need to do anything additional. If desired,
applications can call ksl::useColor() if they need to test for
color.
Also provides the following shell variables that help with colors.
ESC
FG
BG
FG_BLACK
FG_RED
FG_GREEN
FG_YELLOW
FG_BLUE
FG_MAGENTA
FG_CYAN
FG_WHITE
FG_ORANGE
BG_BLACK
BG_RED
BG_GREEN
BG_YELLOW
BG_BLUE
BG_MAGENTA
BG_CYAN
BG_WHITE
BG_ORANGE
CLEAR
BOLD
DIM
UNDERLINE
BLINK
REVERSE
HIDDEN
Index
ksl::isColorCapable
Determines if the terminal is capable of color.
Example
if ksl::isColorCapable; then echo yes; fi
Function has no arguments.
Exit codes
0: terminal is capable of color
1: terminal is not capable of color

ksl::enableColor
Enables color if terminal is capable.
This is called implicitly once, when the libColors.bash is sourced.
Example
ksl::enableColor
Function has no arguments.
Variables set
KSL_USE_COLOR (boolean): set to true or false
Exit codes
0: if terminal is color capable and KSL_USE_COLOR is set to true
1: terminal is not color capable and KSL_USE_COLOR remains unchanged

ksl::disableColor
Disables color.
Example
ksl::disableColor
Function has no arguments.
Variables set
KSL_USE_COLOR (boolean): sets it to false
Exit codes
0: in all cases

ksl::useColor
Returns true if color is enabled.
Example
if ksl::useColor; then echo yes; fi
Function has no arguments.
Variables set
KSL_USE_COLOR (boolean): returns value of this variable
Exit codes
0: if KSL_USE_COLOR is true
1: if KSL_USE_COLOR is false
