wdbashfunctions my Bash extra's for coloring, help, installation
doc generated from the script with gendoc
bash script, version=1.06


source wdbashfunctions
for use in scripts or ~/.bashrc
wdbashfunctions -[h|H|V]
for help on the command line


print short help and exit
display full documentation with less and exit
print version and exit


wdbashfunctions defines functions and environment variables which I use in many, if not all, of my Bash scripts. It is meant to be sourced in ~/.bashrc.

Color functions

There are 32 3-letter commands which print their arguments, each on a new line, in color. The commands Bla, Red, Gre, Yel, Blu, Mag, Cya, and Whi print their arguments, separated with newlines, in black, red, yellow, blue, magenta, cyan and white respectively. The same commands with their second character capitalized print the same colors in a lighter variant. By capitalizing the third character, the arguments are printed in bold face. By captializing all characters, the arguments are printed in bold face in the light color variant.

If the first argument is on, a second 3-letter argument is expected which specifies the background color. Capitalizing the third (bold face) character has no significance here of course. Instead, it will cause the argument to blink.

In short:

  Red -> red
  REd -> light red
  RED -> light bold red
  Red on Yel -> red on yellow
  Red on YEl -> red on light yellow
  Red on YEL -> blinking red on light yellow
  RED on YeL -> blinking light bold red on yellow

Color variables

For each of the color functions, an environment variable with the same name is defined and exported. You use these when you want to different colors in the same string. For example, the following prints several color names, each in their own color:

   echo $Red red $REd light red $RED bold light red $BlU bold blue

Utility functions


prints its arguments in light red to standard error, each on a new line, and exits.


prints its arguments in magenta, each on a new line, to standard error.


prints its arguments in magenta, each on a new line, to standard error, but only if $verbose is defined and has the value true.


prints short help for the script


prints full documentation of the script


installs the script in $PREFIX/bin, with html documentation in $PREFIX/bin/html and a man page in $PREFIX/bin/man/man1. This function is not for use by normal users, the administrator call it via the undocumented -I option. It needs two other scripts: instscript and gendoc.


Enable coloring; this is the default.


Disable all coloring. Sets all coloring escape sequences to the empty string.


Wybo Dekker


Released under the GNU General Public License