-
Notifications
You must be signed in to change notification settings - Fork 2
/
bash_colours
70 lines (60 loc) · 2.03 KB
/
bash_colours
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
70
# vim: set filetype=sh:
colourtable () {
# Found this script on http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/x329.html and put it in a function
T='gYw' # The test text
echo -e "\n 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 "
for BG in 40m 41m 42m 43m 44m 45m 46m 47m; do
echo -en "$EINS \033[$FG\033[$BG $T \033[0m";
done
echo;
done
echo
}
colours256 () {
# From: http://mywiki.wooledge.org/BashFAQ/037
local c i j
printf "Standard 16 colors\n"
for ((c = 0; c < 17; c++)); do
printf "|%s%3d%s" "$(tput setaf "$c")" "$c" "$(tput sgr0)"
done
printf "|\n\n"
printf "Colors 16 to 231 for 256 colors\n"
for ((c = 16, i = j = 0; c < 232; c++, i++)); do
printf "|"
((i > 5 && (i = 0, ++j))) && printf " |"
((j > 5 && (j = 0, 1))) && printf "\b \n|"
printf "%s%3d%s" "$(tput setaf "$c")" "$c" "$(tput sgr0)"
done
printf "|\n\n"
printf "Greyscale 232 to 255 for 256 colors\n"
for ((; c < 256; c++)); do
printf "|%s%3d%s" "$(tput setaf "$c")" "$c" "$(tput sgr0)"
done
printf "|\n"
}
# Define colours in params
# Found this list on http://tldp.org/LDP/abs/html/sample-bashrc.html
RED=$(tput setaf 196) # Red
GREEN=$(tput setaf 40) # Green
YELLOW=$(tput setaf 208) # Yellow
ORANGE=$(tput setaf 208) # Orange
BLUE=$(tput setaf 33) # Blue
PURPLE=$(tput setaf 57) # Purple
CYAN=$(tput setaf 45) # Cyan
WHITE=$(tput setaf 231) # White
# Background
BRED=$(tput setab 196) # Red
BGREEN=$(tput setab 40) # Green
BYELLOW=$(tput setab 220) # Yellow
BORANGE=$(tput setab 208) # Orange
BBLUE=$(tput setab 21) # Blue
BPURPLE=$(tput setab 57) # Purple
BCYAN=$(tput setab 45) # Cyan
BWHITE=$(tput setab 231) # White
# Bold
BOLD=$(tput bold)
NC=$(tput sgr0) # Color Reset
ALERT=${White}${BRed} # Bold White on red background