comparison bin/termcolors.sh @ 144:1783152a1fe6

Color template for bash.
author Edho Arief <edho@myconan.net>
date Sun, 02 Oct 2011 04:17:53 +0700
parents
children c3ca45204c4e
comparison
equal deleted inserted replaced
143:719b0687d974 144:1783152a1fe6
1 #!/bin/sh
2
3 _c() {
4 color_name="${1}"
5 shift
6 text="${*}"
7 esq="\033["
8 r="${esq}0m" # r for reset
9 case "${color_name}" in
10 bold_*) color="1;";;
11 *) color="0;";;
12 esac
13 case "${color_name}" in
14 *black) color="${color}30";;
15 *blue) color="${color}34";;
16 *green) color="${color}32";;
17 *cyan) color="${color}36";;
18 *red) color="${color}31";;
19 *purple) color="${color}35";;
20 *brown) color="${color}33";;
21 *gray) color="${color}37";;
22 esac
23 color="${esq}${color}m"
24 printf "${color}%s${r}" "${text}"
25 }
26