/shell-colors

basher package to provide convenient ANSI escape sequences for colors

Primary LanguageShell

shell-colors Build Status

This is a basher package that provides convenient functions to handle ANSI escape sequences.

Usage

Install this package with the following command:

basher install gibatronic/shell-colors

Then source the library in your script with:

. $(shell-colors library-path)

Example

Ask for the person's name, then print it in blue along with a nice message:

#!/usr/bin/env bash

. $(shell-colors library-path)

read -p 'What'"'"'s your name? ' NAME
echo -n 'Hi '
color_blue $NAME
echo ', nice to meet you!'

Functions

After sourcing the library, the following functions will be available:

color_black <string>
color_blue <string>
color_cyan <string>
color_green <string>
color_magenta <string>
color_red <string>
color_white <string>
color_yellow <string>