File: colors.sh

package info (click to toggle)
clifm 1.26.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,816 kB
  • sloc: ansic: 64,595; sh: 3,133; python: 1,851; makefile: 567
file content (62 lines) | stat: -rwxr-xr-x 1,623 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/sh

# Terminal colors test script for Clifm
# Written by L. Abramovich
# License GPL2+

name="${CLIFM_PLUGIN_NAME:-$(basename "$0")}"

USAGE="Usage: $name [16, 256, test]"

if [ "$1" = "--help" ] || [ "$1" = "-h" ]; then
	printf "Terminal colors test script for Clifm\n"
	printf "\n\x1b[1mUSAGE\x1b[0m\n  %s [16, 256, test]\n" "$name"
	exit 1
fi

opt="${1:-test}"

if [ "$opt" = "256" ]; then
	printf "256 Colors\n"
	for fgbg in $(seq 38 48) ; do
		for color in $(seq 0 256); do #Colors
			for attr in 0 1 2 4 5 7; do
				printf "\e[%s;%s;5;%sm%s;%s;5;%s\e[0;39;49m " "${attr}" "${fgbg}" "${color}" "${attr}" "${fgbg}" "${color}"
			done
			echo
	        done
	        echo
	done

elif [ "$opt" = "16" ]; then
	printf "16 colors\n"
	for clbg in $(seq 40 47) $(seq 100 107) 49 ; do
	        for clfg in $(seq 30 37) $(seq 90 97) 39 ; do
	                for attr in 0 1 2 4 5 7 ; do
						printf "\e[%s;%s;%sm%s;%s;%s\e[0;39;49m " "${attr}" "${clbg}" "${clfg}" "${attr}" "${clbg}" "${clfg}"
	                done
	                printf "\n"
	        done
	done

elif [ "$opt" = "test" ]; then
	printf "The word 'test' should be printed in green (using the current terminal background color as background color). If not, then X colors are not supported by this terminal (emulator).\n"

	printf "8 colors (3-bit)\n"
	printf "\e[00;32mtest\e[0m\n\n"

	printf "16 colors (4-bit)\n"
	printf "\e[00;32mtest\e[0m\n\n"

	printf "256 colors (8-bit)\n"
	printf "\e[00;38;5;2mtest\e[0m\n\n"

	printf "RGB, true colors (24-bit)\n"
	printf "\e[00;38;2;20;170;0mtest\e[0m\n\n"

else
	printf "%s\n" "$USAGE" >&2
	exit 1
fi

exit 0