Commit 4fd2a9e0fd57394197991bc5f37052fcbd590955
1 parent
6a4b6fdaa0
Exists in
master
added colors file header
Showing 1 changed file with 2 additions and 0 deletions Inline Diff
scripts/colors.sh
View file @
4fd2a9e
#!/usr/bin/env bash | 1 | 1 | #!/usr/bin/env bash | |
2 | 2 | |||
3 | #this function was taken from: | |||
4 | # https://wiki.archlinux.org/index.php/Color_Bash_Prompt#Colors_overview | |||
3 | 5 | |||
colors() { | 4 | 6 | colors() { | |
local fgc bgc vals seq0 | 5 | 7 | local fgc bgc vals seq0 | |
6 | 8 | |||
printf "Color escapes are %s\n" '\e[${value};...;${value}m' | 7 | 9 | printf "Color escapes are %s\n" '\e[${value};...;${value}m' | |
printf "Values 30..37 are \e[33mforeground colors\e[m\n" | 8 | 10 | printf "Values 30..37 are \e[33mforeground colors\e[m\n" | |
printf "Values 40..47 are \e[43mbackground colors\e[m\n" | 9 | 11 | printf "Values 40..47 are \e[43mbackground colors\e[m\n" | |
printf "Value 1 gives a \e[1mbold-faced look\e[m\n\n" | 10 | 12 | printf "Value 1 gives a \e[1mbold-faced look\e[m\n\n" | |
11 | 13 | |||
# foreground colors | 12 | 14 | # foreground colors | |
for fgc in {30..37}; do | 13 | 15 | for fgc in {30..37}; do | |
# background colors | 14 | 16 | # background colors | |
for bgc in {40..47}; do | 15 | 17 | for bgc in {40..47}; do | |
fgc=${fgc#37} # white | 16 | 18 | fgc=${fgc#37} # white | |
bgc=${bgc#40} # black | 17 | 19 | bgc=${bgc#40} # black | |
18 | 20 | |||
vals="${fgc:+$fgc;}${bgc}" | 19 | 21 | vals="${fgc:+$fgc;}${bgc}" | |
vals=${vals%%;} | 20 | 22 | vals=${vals%%;} | |
21 | 23 | |||
seq0="${vals:+\e[${vals}m}" | 22 | 24 | seq0="${vals:+\e[${vals}m}" | |
printf " %-9s" "${seq0:-(default)}" | 23 | 25 | printf " %-9s" "${seq0:-(default)}" | |
printf " ${seq0}TEXT\e[m" | 24 | 26 | printf " ${seq0}TEXT\e[m" |