summaryrefslogblamecommitdiffstats
path: root/bashrc/common/color.sh
blob: ca6298889fc4a7c2f824e4426ec1eaebb8e67592 (plain) (tree)









































                                                                     
# color code definitions

# print ugly color codes
coco() {
	[[ -z "$1" ]] && echo -ne "\033[0m" || echo -ne "\033[${1}m"
}

# name all colors to get rid of hieroglyphics
color() {
	case $1 in
		black)    coco '0;30' ;;
		dgray)    coco '1;30' ;;
		red)      coco '0;31' ;;
		lred)     coco '1;31' ;;
		green)    coco '0;32' ;;
		lgreen)   coco '1;32' ;;
		brown)    coco '0;33' ;;
		yellow)   coco '1;33' ;;
		blue)     coco '0;34' ;;
		lblue)    coco '1;34' ;;
		purple)   coco '0;35' ;;
		lpurple)  coco '1;35' ;;
		cyan)     coco '0;36' ;;
		lcyan)    coco '1;36' ;;
		lgray)    coco '0;37' ;;
		white)    coco '1;37' ;;
		*)        coco '0' ;;
	esac
}

pcolor() {
	echo -ne "\[$(color $@)\]"
}

colors() {
	local l="black dgray red lred green lgreen brown yellow blue"
	local l="${l} lblue purple lpurple cyan lcyan lgray white"
	
	for i in $l; do
		echo "$i = $(color $i)$i$(color)"
	done
}