90 lines
3.1 KiB
Bash
Executable file
90 lines
3.1 KiB
Bash
Executable file
#!/bin/zsh
|
|
|
|
# prcolors: Display all colors in a few different ways >>>
|
|
# TODO: change this to make it not just a few scripts smashed together
|
|
|
|
if [ "$1" -gt 0 ] && [ "$1" -lt 4 ]; then
|
|
if [ $1 = '1' ];then
|
|
# Taken from manjaro's bashrc >>>
|
|
local fgc bgc vals seq0
|
|
|
|
printf "Color escapes are %s\n" '\e[${value};...;${value}m'
|
|
printf "Values 30..37 are \e[33mforeground colors\e[m\n"
|
|
printf "Values 40..47 are \e[43mbackground colors\e[m\n"
|
|
printf "Value 1 gives a \e[1mbold-faced look\e[m\n\n"
|
|
|
|
# foreground colors
|
|
for fgc in {30..37}; do
|
|
# background colors
|
|
for bgc in {40..47}; do
|
|
fgc=${fgc#37} # white
|
|
bgc=${bgc#40} # black
|
|
|
|
vals="${fgc:+$fgc;}${bgc}"
|
|
vals=${vals%%;}
|
|
|
|
seq0="${vals:+\e[${vals}m}"
|
|
printf " %-9s" "${seq0:-(default)}"
|
|
printf " ${seq0}TEXT\e[m"
|
|
printf " \e[${vals:+${vals+$vals;}}1mBOLD\e[m"
|
|
done
|
|
echo; echo
|
|
done
|
|
# <<<
|
|
elif [ $1 = '2' ];then
|
|
# from base16shell >>>
|
|
ansi_mappings=(
|
|
Red Green
|
|
Yellow Blue
|
|
Magenta Cyan
|
|
White Black
|
|
Bright_Red Bright_Green
|
|
Bright_Yellow Bright_Blue
|
|
Bright_Magenta Bright_Cyan
|
|
Bright_White Bright_Black
|
|
)
|
|
colors=(
|
|
base00 base08
|
|
base0B base0A
|
|
base0D base0E
|
|
base0C base05
|
|
base03 base08
|
|
base0B base0A
|
|
base0D base0E
|
|
base0C base07
|
|
base09 base0F
|
|
base01 base02
|
|
base04 base06
|
|
)
|
|
for padded_value in `seq -w 0 21`; do
|
|
color_variable="color${padded_value}"
|
|
eval current_color=\$${color_variable}
|
|
current_color=$(echo ${current_color//\//} | tr '[:lower:]' '[:upper:]') # get rid of slashes, and uppercase
|
|
non_padded_value=$((10#$padded_value))
|
|
base16_color_name=${colors[$non_padded_value]}
|
|
current_color_label=${current_color:-unknown}
|
|
ansi_label=${ansi_mappings[$non_padded_value]}
|
|
block=$(printf "\x1b[48;5;${non_padded_value}m___________________________")
|
|
foreground=$(printf "\x1b[38;5;${non_padded_value}m$color_variable")
|
|
printf "%s %s %s %-30s %s\x1b[0m\n" $foreground $base16_color_name $current_color_label ${ansi_label:-""} $block
|
|
done;
|
|
#if [ $# -eq 1 ]; then
|
|
# printf "To restore current theme, source ~/.base16_theme or reopen your terminal\n"
|
|
#fi
|
|
# <<<
|
|
elif [ $1 = '3' ];then
|
|
# Similar to above, but does 256-bit colors. >>>
|
|
# Taken from this: https://github.com/romkatv/powerlevel10k#set-colors-through-Powerlevel10k-configuration-parameters
|
|
for i in {0..255}; do print -Pn "%K{$i} %k%F{$i}${(l:3::0:)i}%f " ${${(M)$((i%6)):#3}:+$'\n'}; done
|
|
# <<<
|
|
fi
|
|
else
|
|
cat <<-EOF
|
|
Usage: prcolors <printing method number>
|
|
1: Manjaro bashrc -- for checking text readability
|
|
2: base26shell -- for seeing the 16 set terminal colors
|
|
3: 256 -- for testing 256 color output
|
|
EOF
|
|
fi
|
|
|
|
# vim:foldmarker=>>>,<<< fdm=marker foldlevel=1
|