aboutsummaryrefslogtreecommitdiff
path: root/functions
diff options
context:
space:
mode:
authorSebastien Luttringer <seblu@seblu.net>2011-05-04 23:35:25 +0200
committerSebastien Luttringer <seblu@seblu.net>2011-05-21 18:41:19 +0200
commit1ba11e7f78af5742dbc211d9202db4549558ca44 (patch)
tree40b965f256ad286c7d3f231230b660e2f93c5506 /functions
parentd1be877eb0ad3be634cee08aada8f8d1265023a4 (diff)
downloadinitscripts-1ba11e7f78af5742dbc211d9202db4549558ca44.tar.xz
Improve coloring on light and transparent term
This patch improve coloring in light and transparent term. It uses tput if available or default color code. It remplace \033 by \e. It's a kind of rollback from commit 65f410, because initscripts are now in bash, and argument "\e isn't recongized in all shells" is not an issue anymore. This is not done in locale.sh script which can be sourced by others shell, so we try to be the more compliant as possible Signed-off-by: Sebastien Luttringer <seblu@seblu.net>
Diffstat (limited to 'functions')
-rw-r--r--functions47
1 files changed, 28 insertions, 19 deletions
diff --git a/functions b/functions
index 6d279cc..27e53d0 100644
--- a/functions
+++ b/functions
@@ -49,28 +49,37 @@ else
export LANG=C
fi
-# colors:
-if [[ $USECOLOR = YES || $USECOLOR = yes ]]; then
- C_MAIN="\033[1;37;40m" # main text
-
- C_OTHER="\033[1;34;40m" # prefix & brackets
- C_SEPARATOR="\033[1;30;40m" # separator
-
- C_BUSY="\033[0;36;40m" # busy
- C_FAIL="\033[1;31;40m" # failed
- C_DONE="\033[1;37;40m" # completed
- C_BKGD="\033[1;35;40m" # backgrounded
-
- C_H1="\033[1;37;40m" # highlight text 1
- C_H2="\033[1;36;40m" # highlight text 2
-
- C_CLEAR="\033[1;0m"
+# set colors
+if [[ $USECOLOR =~ yes|YES ]]; then
+ if /bin/tput setaf 0 &>/dev/null; then
+ C_CLEAR="$(tput sgr0)" # clear text
+ C_MAIN="${C_CLEAR}$(/bin/tput bold)" # main text
+ C_OTHER="${C_MAIN}$(/bin/tput setaf 4)" # prefix & brackets
+ C_SEPARATOR="${C_MAIN}$(/bin/tput setaf 0)" # separator
+ C_BUSY="${C_CLEAR}$(/bin/tput setaf 6)" # busy
+ C_FAIL="${C_MAIN}$(/bin/tput setaf 1)" # failed
+ C_DONE="${C_MAIN}" # completed
+ C_BKGD="${C_MAIN}$(/bin/tput setaf 5)" # backgrounded
+ C_H1="${C_MAIN}" # highlight text 1
+ C_H2="${C_MAIN}$(/bin/tput setaf 6)" # highlight text 2
+ else
+ C_CLEAR="\e[m" # clear text
+ C_MAIN="\e[;1m" # main text
+ C_OTHER="\e[1;34m" # prefix & brackets
+ C_SEPARATOR="\e[1;30m" # separator
+ C_BUSY="\e[;36m" # busy
+ C_FAIL="\e[1;31m" # failed
+ C_DONE="${C_MAIN}" # completed
+ C_BKGD="\e[1;35m" # backgrounded
+ C_H1="${$C_MAIN}" # highlight text 1
+ C_H2="\e[1;36m" # highlight text 2
+ fi
fi
if [[ -t 1 ]]; then
- SAVE_POSITION="\033[s"
- RESTORE_POSITION="\033[u"
- DEL_TEXT="\033[$(($STAT_COL+4))G"
+ SAVE_POSITION="\e[s"
+ RESTORE_POSITION="\e[u"
+ DEL_TEXT="\e[$(($STAT_COL+4))G"
else
SAVE_POSITION=""
RESTORE_POSITION=""