-
Notifications
You must be signed in to change notification settings - Fork 0
/
ansi
executable file
·50 lines (46 loc) · 1.59 KB
/
ansi
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
#!/usr/bin/bash
# bash script to quickly find ansi escape sequences
echo "Starting sequence: either \\033[ or \\x1b[ or \\e["
echo ""
echo "Reset codes:"
echo " - \\033[0m -> reset style and colors"
echo " - \\033[38m -> reset foreground color"
echo " - \\033[48m -> reset background color"
echo ""
echo "16 color mode :"
color_names=("Black " "Red " "Green " "Orange" "Blue " "Purple" "Cyan " "White ")
color_codes=(30 31 32 33 34 35 36 37)
echo " Normal Bold Faint Italics Underlined Background"
for i in {0..7}; do
code=${color_codes[i]}
start=${color_names[i]}
for offset in {0,60}; do
code=$((color_codes[i]+offset))
bg=$((code+10))
echo -n "$start"
echo -en " \033[${code}m"'\\033['"$code"'m'"\033[0m"
echo -en " \033[$code;1m"'\\033['"$code"';1m'"\033[0m"
echo -en " \033[$code;2m"'\\033['"$code"';2m'"\033[0m"
echo -en " \033[$code;3m"'\\033['"$code"';3m'"\033[0m"
echo -en " \033[$code;4m"'\\033['"$code"';4m'"\033[0m"
echo -e " \033[${bg}m"'\\033['"$bg"'m'"\033[0m"
start=" "
done
done
echo ""
echo "Styles :"
style_on=( 1 2 3 4 5 7 9 51 52 53)
style_off=(22 22 23 24 25 0 29 54 54 55)
echo " Bold Faint Italics Underline Blink Inverse Barred Framed Circle Overline"
echo -n "On: "
for i in {0..9}; do
echo -en "\033[${style_on[i]}m"'\\033['"${style_on[i]}"'m'"\033[${style_off[i]}m "
if [ $i -lt 5 ]; then echo -n " "; fi
if [ $i -eq 6 ]; then echo -n " "; fi
done
echo ""
echo -n "Off: "
for i in {0..9}; do
echo -en "\033[${style_on[i]}m"'\\033['"${style_off[i]}"'m'"\033[${style_off[i]}m "
done
echo ""