-
Notifications
You must be signed in to change notification settings - Fork 95
/
Copy pathcolors
executable file
·69 lines (60 loc) · 2.06 KB
/
colors
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
63
64
65
66
67
68
69
#!/bin/bash
#
# Display supported terminal color palette and available text effects.
#
# - Display the palette:
#
# `colors`
#
# ---
# Author: Nick Plekhanov, https://nikkhan.com/
# License: MIT
# https://github.com/nicksp/dotfiles
set -euo pipefail
CYAN="$(tput setaf 6)"
UNDERLINE="$(tput sgr 0 1)"
RESET="$(tput sgr0)"
title() {
echo
echo -e "${UNDERLINE}${CYAN}${1}${RESET}"
echo
}
# Represent the 16 base colors in the 256-color palette
for row in {0..15}; do
# Represent the 16 shades of each base color
for col in {0..15}; do
color=$((row * 16 + col))
color_code=$(printf "%03d" $color)
echo -en "\033[48;5;${color}m\033[1m $color_code \033[0m\033[38;5;${color}m\033[0m"
done
echo
done
title "Escape sequences"
echo "Effects:"
echo -e "1: \033[1mBold\033[0m"
echo -e "2: \033[2mDimmed\033[0m"
echo -e "3: \033[3mItalic\033[0m"
echo -e "4: \033[4mUnderline\033[0m"
echo -e "5: \033[5mBlinking\033[0m"
echo -e "6: \033[6mBlinking fast\033[0m"
echo -e "7: \033[7mInverted\033[0m"
echo -e "8 (invisible): \033[8mInvisible\033[0m"
echo
echo "Examples:"
echo -e "\\\033\[33;44;1m \033[33;44;1myellow on blue, bold\033[0m \\\033\[0m"
echo -e "\\\033\[38;5;219m \033[38;5;219m256-color foreground\033[0m \\\033\[0m"
echo -e "\\\033\[48;5;61m \033[48;5;61m256-color background\033[0m \\\033\[0m"
title "Tput commands"
echo "Effects:"
echo "bold: $(tput bold)Bold$RESET"
echo "dim: $(tput dim)Dim$RESET"
echo "sitm: $(tput sitm)Italic$RESET"
echo "smul: $(tput smul)Underline$RESET"
echo "blink: $(tput blink)Blinking$RESET"
echo "rev: $(tput rev)Inverted$RESET"
echo "invis: $(tput invis)Invisible$RESET"
echo
echo "Examples:"
echo "\$(tput setaf 3)\$(tput setab 4)\$(tput bold) $(tput setaf 3)$(tput setab 4)$(tput bold)$(tput)yellow on blue, bold$RESET \$(tput sgr0)"
echo "\$(tput setaf 153) $(tput setaf 153)256-color foreground$RESET \$(tput sgr0)"
echo "\$(tput setab 128) $(tput setab 128)256-color background$RESET \$(tput sgr0)"