#!/bin/bash # /KNOPPIX/etc/init.d/colors.sh # (C) Klaus Knopper 2001 # jc@jcomeau.com's cleanup of color code (no embedded escape sequences) # ANSI COLORS CR="$(echo -e '\r')" ESC="$(echo -e '\033')" CRE="$CR$ESC[K" NORMAL="$ESC[0;39m" message () { echo "$NORMAL$@" } # RED: Failure or error message RED="$ESC[1;31m" error () { echo "$RED$@$NORMAL" } # GREEN: Success message GREEN="$ESC[1;32m" success () { echo "$GREEN$@$NORMAL" } # YELLOW: Descriptions YELLOW="$ESC[1;33m" describe () { echo "$YELLOW$@$NORMAL" } # BLUE: System messages BLUE="$ESC[1;34m" system () { echo "$BLUE$@$NORMAL" } # MAGENTA: Found devices or drivers MAGENTA="$ESC[1;35m" found () { echo "$MAGENTA$@$NORMAL" } # CYAN: Questions CYAN="$ESC[1;36m" query () { echo -n "$CYAN$@$NORMAL" } # BOLD WHITE: Hint WHITE="$ESC[1;37m" hint () { echo "$WHITE$@$NORMAL" } if [ "$(basename $0)" = "colors.sh" ]; then echo "Testing script... to avoid this, invoke using '. colors.sh'" echo -n "This should disappear in 3 seconds..." sleep 3 echo $CRE message "This is a normal message" error "This signifies an error" success "This identifies a successful operation" describe "This is a descriptive message" system "This signifies a system message" found "This is used to indicate some software or hardware was found" query "Queries should appear in cyan: does this? " read -t 3 ignore || error "timeout!" hint "Finally, hints are in bold" message "Test complete." fi