aboutsummaryrefslogtreecommitdiffstats
path: root/unix
diff options
context:
space:
mode:
authorAaron LI <aly@aaronly.me>2017-11-03 18:51:22 +0800
committerAaron LI <aly@aaronly.me>2017-11-03 18:51:22 +0800
commite148cb4ec090da55cfc3f00dc1631900e48e0892 (patch)
treed9896f619c5e898bf88a6489e263178bd75e5343 /unix
parent5a8b44ee3328464a673c2be2e21873fb02f1425b (diff)
downloadatoolbox-e148cb4ec090da55cfc3f00dc1631900e48e0892.tar.bz2
Update termcolors1 to not depend on bash; update termcolors2 a bit
Diffstat (limited to 'unix')
-rwxr-xr-xunix/termcolors1.sh (renamed from unix/termcolors1.bash)17
-rwxr-xr-xunix/termcolors2.bash68
2 files changed, 51 insertions, 34 deletions
diff --git a/unix/termcolors1.bash b/unix/termcolors1.sh
index f9efa62..23c4f06 100755
--- a/unix/termcolors1.bash
+++ b/unix/termcolors1.sh
@@ -1,10 +1,10 @@
-#!/usr/bin/env bash
+#!/bin/sh
#
# * https://gist.github.com/esundahl/1651086
# * https://wiki.archlinux.org/index.php/X_resources
#
-function color_test {
+color_test() {
# Daniel Crisman's ANSI color chart script from
# The Bash Prompt HOWTO: 6.1. Colours
# http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/x329.html
@@ -17,21 +17,22 @@ function color_test {
# colors (default + 8 escapes).
#
- T='gYw' # The test text
+ T="gYw" # The test text
- echo -e "\n 40m 41m 42m 43m\
+ echo
+ echo " 40m 41m 42m 43m\
44m 45m 46m 47m"
for FGs in ' m' ' 1m' ' 30m' '1;30m' ' 31m' '1;31m' \
' 32m' '1;32m' ' 33m' '1;33m' ' 34m' '1;34m' \
' 35m' '1;35m' ' 36m' '1;36m' ' 37m' '1;37m';
do
- FG=${FGs// /}
- echo -en " $FGs \033[$FG $T "
+ FG=`echo "${FGs}" | tr -d ' '`
+ echo -n " $FGs \033[$FG $T "
for BG in 40m 41m 42m 43m 44m 45m 46m 47m; do
- echo -en "$EINS \033[$FG\033[$BG $T \033[0m"
+ echo -n "$EINS \033[$FG\033[$BG $T \033[0m"
done
- echo;
+ echo
done
echo
}
diff --git a/unix/termcolors2.bash b/unix/termcolors2.bash
index 4dc2ef2..def8b3e 100755
--- a/unix/termcolors2.bash
+++ b/unix/termcolors2.bash
@@ -1,32 +1,48 @@
#!/usr/bin/env bash
-# Original: http://frexx.de/xterm-256-notes/
-# http://frexx.de/xterm-256-notes/data/colortable16.sh
-# Modified by Aaron Griffin
-# and further by Kazuo Teramoto
+#
+# Credits:
+# [1] http://frexx.de/xterm-256-notes/data/colortable16.sh
+# [2] https://wiki.archlinux.org/index.php/X_resources
+#
+# Modified by Aaron Griffin, and Kazuo Teramoto
+#
+
+
FGNAMES=(' black ' ' red ' ' green ' ' yellow' ' blue ' 'magenta' ' cyan ' ' white ')
BGNAMES=('DFT' 'BLK' 'RED' 'GRN' 'YEL' 'BLU' 'MAG' 'CYN' 'WHT')
-
+#echo " ----------------------------------------------------------------------------"
echo " ┌──────────────────────────────────────────────────────────────────────────┐"
-for b in {0..8}; do
- ((b>0)) && bg=$((b+39))
-
- echo -en "\033[0m ${BGNAMES[b]} │ "
-
- for f in {0..7}; do
- echo -en "\033[${bg}m\033[$((f+30))m ${FGNAMES[f]} "
- done
-
- echo -en "\033[0m │"
- echo -en "\033[0m\n\033[0m │ "
-
- for f in {0..7}; do
- echo -en "\033[${bg}m\033[1;$((f+30))m ${FGNAMES[f]} "
- done
-
- echo -en "\033[0m │"
- echo -e "\033[0m"
-
- ((b<8)) &&
- echo " ├──────────────────────────────────────────────────────────────────────────┤"
+for b in $(seq 0 8); do
+ if [ "$b" -gt 0 ]; then
+ bg=$(($b+39))
+ fi
+
+ #echo -en "\033[0m ${BGNAMES[$b]} : "
+ echo -en "\033[0m ${BGNAMES[$b]} │ "
+
+ for f in $(seq 0 7); do
+ fg=$(($f+30))
+ echo -en "\033[${bg}m\033[${fg}m ${FGNAMES[$f]} "
+ done
+
+ #echo -en "\033[0m :"
+ #echo -en "\033[0m\n\033[0m : "
+ echo -en "\033[0m │"
+ echo -en "\033[0m\n\033[0m │ "
+
+ for f in $(seq 0 7); do
+ fg=$(($f+30))
+ echo -en "\033[${bg}m\033[1;${fg}m ${FGNAMES[$f]} "
+ done
+
+ #echo -en "\033[0m :"
+ echo -en "\033[0m │"
+ echo -e "\033[0m"
+
+ if [ "$b" -lt 8 ]; then
+ #echo " ----------------------------------------------------------------------------"
+ echo " ├──────────────────────────────────────────────────────────────────────────┤"
+ fi
done
+#echo " ----------------------------------------------------------------------------"
echo " └──────────────────────────────────────────────────────────────────────────┘"