Skip to content

Instantly share code, notes, and snippets.

@32teeth
Created October 9, 2024 17:46
Show Gist options
  • Save 32teeth/24f46daabe547a3f5a72e18c825d364f to your computer and use it in GitHub Desktop.
Save 32teeth/24f46daabe547a3f5a72e18c825d364f to your computer and use it in GitHub Desktop.
Color Generator
IndianRed=''
LightCoral=''
Salmon=''
DarkSalmon=''
LightSalmon=''
Crimson=''
Red=''
FireBrick=''
DarkRed=''
Pink=''
LightPink=''
HotPink=''
DeepPink=''
MediumVioletRed=''
PaleVioletRed=''
LightSalmon=''
Coral=''
Tomato=''
OrangeRed=''
DarkOrange=''
Orange=''
Gold=''
Yellow=''
LightYellow=''
LemonChiffon=''
LightGoldenrodYellow=''
PapayaWhip=''
Moccasin=''
PeachPuff=''
PaleGoldenrod=''
Khaki=''
DarkKhaki=''
Lavender=''
Thistle=''
Plum=''
Violet=''
Orchid=''
Fuchsia=''
Magenta=''
MediumOrchid=''
MediumPurple=''
RebeccaPurple=''
BlueViolet=''
DarkViolet=''
DarkOrchid=''
DarkMagenta=''
Purple=''
Indigo=''
SlateBlue=''
DarkSlateBlue=''
MediumSlateBlue=''
GreenYellow=''
Chartreuse=''
LawnGreen=''
Lime=''
LimeGreen=''
PaleGreen=''
LightGreen=''
MediumSpringGreen=''
SpringGreen=''
MediumSeaGreen=''
SeaGreen=''
ForestGreen=''
Green=''
DarkGreen=''
YellowGreen=''
OliveDrab=''
Olive=''
DarkOliveGreen=''
MediumAquamarine=''
DarkSeaGreen=''
LightSeaGreen=''
DarkCyan=''
Teal=''
Aqua=''
Cyan=''
LightCyan=''
PaleTurquoise=''
Aquamarine=''
Turquoise=''
MediumTurquoise=''
DarkTurquoise=''
CadetBlue=''
SteelBlue=''
LightSteelBlue=''
PowderBlue=''
LightBlue=''
SkyBlue=''
LightSkyBlue=''
DeepSkyBlue=''
DodgerBlue=''
CornflowerBlue=''
MediumSlateBlue=''
RoyalBlue=''
Blue=''
MediumBlue=''
DarkBlue=''
Navy=''
MidnightBlue=''
Cornsilk=''
BlanchedAlmond=''
Bisque=''
NavajoWhite=''
Wheat=''
BurlyWood=''
Tan=''
RosyBrown=''
SandyBrown=''
Goldenrod=''
DarkGoldenrod=''
Peru=''
Chocolate=''
SaddleBrown=''
Sienna=''
Brown=''
Maroon=''
White=''
Snow=''
HoneyDew=''
MintCream=''
Azure=''
AliceBlue=''
GhostWhite=''
WhiteSmoke=''
SeaShell=''
Beige=''
OldLace=''
FloralWhite=''
Ivory=''
AntiqueWhite=''
Linen=''
LavenderBlush=''
MistyRose=''
Gainsboro=''
LightGray=''
Silver=''
DarkGray=''
Gray=''
DimGray=''
LightSlateGray=''
SlateGray=''
DarkSlateGray=''
Black=''
bgIndianRed=''
bgLightCoral=''
bgSalmon=''
bgDarkSalmon=''
bgLightSalmon=''
bgCrimson=''
bgRed=''
bgFireBrick=''
bgDarkRed=''
bgPink=''
bgLightPink=''
bgHotPink=''
bgDeepPink=''
bgMediumVioletRed=''
bgPaleVioletRed=''
bgLightSalmon=''
bgCoral=''
bgTomato=''
bgOrangeRed=''
bgDarkOrange=''
bgOrange=''
bgGold=''
bgYellow=''
bgLightYellow=''
bgLemonChiffon=''
bgLightGoldenrodYellow=''
bgPapayaWhip=''
bgMoccasin=''
bgPeachPuff=''
bgPaleGoldenrod=''
bgKhaki=''
bgDarkKhaki=''
bgLavender=''
bgThistle=''
bgPlum=''
bgViolet=''
bgOrchid=''
bgFuchsia=''
bgMagenta=''
bgMediumOrchid=''
bgMediumPurple=''
bgRebeccaPurple=''
bgBlueViolet=''
bgDarkViolet=''
bgDarkOrchid=''
bgDarkMagenta=''
bgPurple=''
bgIndigo=''
bgSlateBlue=''
bgDarkSlateBlue=''
bgMediumSlateBlue=''
bgGreenYellow=''
bgChartreuse=''
bgLawnGreen=''
bgLime=''
bgLimeGreen=''
bgPaleGreen=''
bgLightGreen=''
bgMediumSpringGreen=''
bgSpringGreen=''
bgMediumSeaGreen=''
bgSeaGreen=''
bgForestGreen=''
bgGreen=''
bgDarkGreen=''
bgYellowGreen=''
bgOliveDrab=''
bgOlive=''
bgDarkOliveGreen=''
bgMediumAquamarine=''
bgDarkSeaGreen=''
bgLightSeaGreen=''
bgDarkCyan=''
bgTeal=''
bgAqua=''
bgCyan=''
bgLightCyan=''
bgPaleTurquoise=''
bgAquamarine=''
bgTurquoise=''
bgMediumTurquoise=''
bgDarkTurquoise=''
bgCadetBlue=''
bgSteelBlue=''
bgLightSteelBlue=''
bgPowderBlue=''
bgLightBlue=''
bgSkyBlue=''
bgLightSkyBlue=''
bgDeepSkyBlue=''
bgDodgerBlue=''
bgCornflowerBlue=''
bgMediumSlateBlue=''
bgRoyalBlue=''
bgBlue=''
bgMediumBlue=''
bgDarkBlue=''
bgNavy=''
bgMidnightBlue=''
bgCornsilk=''
bgBlanchedAlmond=''
bgBisque=''
bgNavajoWhite=''
bgWheat=''
bgBurlyWood=''
bgTan=''
bgRosyBrown=''
bgSandyBrown=''
bgGoldenrod=''
bgDarkGoldenrod=''
bgPeru=''
bgChocolate=''
bgSaddleBrown=''
bgSienna=''
bgBrown=''
bgMaroon=''
bgWhite=''
bgSnow=''
bgHoneyDew=''
bgMintCream=''
bgAzure=''
bgAliceBlue=''
bgGhostWhite=''
bgWhiteSmoke=''
bgSeaShell=''
bgBeige=''
bgOldLace=''
bgFloralWhite=''
bgIvory=''
bgAntiqueWhite=''
bgLinen=''
bgLavenderBlush=''
bgMistyRose=''
bgGainsboro=''
bgLightGray=''
bgSilver=''
bgDarkGray=''
bgGray=''
bgDimGray=''
bgLightSlateGray=''
bgSlateGray=''
bgDarkSlateGray=''
bgBlack=''
#!/bin/bash
# Source the styles.sh file which contains fg and bg colors
source styles.sh
# Function to strip ANSI escape codes (for correct length calculation)
strip_ansi() {
echo -e "$1" | sed 's/\x1B\[[0-9;]*[mK]//g'
}
# Function to create the table with colors
table() {
clear
local format="| %-25s | %-30s |\n"
local repeat=79 # Adjusted to fit the width of the table with borders
if [ -n "$1" ]; then
local title=${bold}${White}$1${nc}
else
local title="no title"
fi
# Table header with title
printf "+%s+%s+\n" "$(printf '%.0s-' {1..27})" "$(printf '%.0s-' {1..32})"
printf "| %-${repeat}s |\n" "$title" # Title spans across both columns
printf "+%s+%s+\n" "$(printf '%.0s-' {1..27})" "$(printf '%.0s-' {1..32})"
# Header for Foreground and Background
printf "$format" "$(printf '%s%-25s%s' "$bold" "Foreground" "$nc")" "$(printf '%s%-30s%s' "$bold" "Background" "$nc")"
printf "+%s+%s+\n" "$(printf '%.0s-' {1..27})" "$(printf '%.0s-' {1..32})"
# Extract all color names from `colors.sh` (assuming all color names follow fgColorName/bgColorName pattern)
color_names=$(grep -o '^[a-zA-Z]\+' colors.sh | grep -v '^bg')
# Iterate over all extracted colors
for color_name in $color_names; do
# Strip ANSI escape sequences for formatting
stripped_fg_color_name=$(strip_ansi "$color_name")
stripped_bg_color_name=$(strip_ansi "bg${color_name}")
# Use eval to get color values dynamically
eval fg="\$${color_name}"
eval bg="\$bg${color_name}"
# Print each color in its respective foreground and background format with borders
printf "$format" "$(printf '%s%-25s%s' "$fg" "$stripped_fg_color_name" "$nc")" "$(printf '%s%-30s%s' "$bg" "$stripped_bg_color_name" "$nc")"
done
# Table footer
printf "+%s+%s+\n" "$(printf '%.0s-' {1..27})" "$(printf '%.0s-' {1..32})"
}
# Call the table function
table "Color Table"
#!/bin/bash
fg_colors=()
bg_colors=()
hexToAnsiColors() {
local color_name="$1"
local hex="$2"
hex=${hex#"#"}
r=$(printf '0x%0.2s' "$hex")
g=$(printf '0x%0.2s' ${hex#??})
b=$(printf '0x%0.2s' ${hex#????})
local ansi_code="$(( (r<75?0:(r-35)/40)*6*6 +
(g<75?0:(g-35)/40)*6 +
(b<75?0:(b-35)/40) + 16 ))"
local fgColor=$(printf '\e[38;5;%dm' "$ansi_code")
local bgColor=$(printf '\e[48;5;%dm' "$ansi_code")
# Store the color variables in arrays instead of appending directly
fg_colors+=("${color_name}='${fgColor}'")
bg_colors+=("bg${color_name}='${bgColor}'")
}
# Clear or create colors.sh in one step
> colors.sh
#---------------------------------
# FANCY STUFF
#---------------------------------
nc=$(tput sgr0 || printf '\033[0m') # Fallback if tput fails
bold=$(tput bold || printf '\033[1m')
italic=$(tput sitm || printf '\033[3m')
# reds
reds=(
"IndianRed #CD5C5C"
"LightCoral #F08080"
"Salmon #FA8072"
"DarkSalmon #E9967A"
"LightSalmon #FFA07A"
"Crimson #DC143C"
"Red #FF0000"
"FireBrick #B22222"
"DarkRed #8B0000"
)
# pinks
pinks=(
"Pink #FFC0CB"
"LightPink #FFB6C1"
"HotPink #FF69B4"
"DeepPink #FF1493"
"MediumVioletRed #C71585"
"PaleVioletRed #DB7093"
)
# oranges
oranges=(
"LightSalmon #FFA07A"
"Coral #FF7F50"
"Tomato #FF6347"
"OrangeRed #FF4500"
"DarkOrange #FF8C00"
"Orange #FFA500"
)
# yellows
yellows=(
"Gold #FFD700"
"Yellow #FFFF00"
"LightYellow #FFFFE0"
"LemonChiffon #FFFACD"
"LightGoldenrodYellow #FAFAD2"
"PapayaWhip #FFEFD5"
"Moccasin #FFE4B5"
"PeachPuff #FFDAB9"
"PaleGoldenrod #EEE8AA"
"Khaki #F0E68C"
"DarkKhaki #BDB76B"
)
# purples
purples=(
"Lavender #E6E6FA"
"Thistle #D8BFD8"
"Plum #DDA0DD"
"Violet #EE82EE"
"Orchid #DA70D6"
"Fuchsia #FF00FF"
"Magenta #FF00FF"
"MediumOrchid #BA55D3"
"MediumPurple #9370DB"
"RebeccaPurple #663399"
"BlueViolet #8A2BE2"
"DarkViolet #9400D3"
"DarkOrchid #9932CC"
"DarkMagenta #8B008B"
"Purple #800080"
"Indigo #4B0082"
"SlateBlue #6A5ACD"
"DarkSlateBlue #483D8B"
"MediumSlateBlue #7B68EE"
)
# greens
greens=(
"GreenYellow #ADFF2F"
"Chartreuse #7FFF00"
"LawnGreen #7CFC00"
"Lime #00FF00"
"LimeGreen #32CD32"
"PaleGreen #98FB98"
"LightGreen #90EE90"
"MediumSpringGreen #00FA9A"
"SpringGreen #00FF7F"
"MediumSeaGreen #3CB371"
"SeaGreen #2E8B57"
"ForestGreen #228B22"
"Green #008000"
"DarkGreen #006400"
"YellowGreen #9ACD32"
"OliveDrab #6B8E23"
"Olive #808000"
"DarkOliveGreen #556B2F"
"MediumAquamarine #66CDAA"
"DarkSeaGreen #8FBC8B"
"LightSeaGreen #20B2AA"
"DarkCyan #008B8B"
"Teal #008080"
)
# blues
blues_and_cyans=(
"Aqua #00FFFF"
"Cyan #00FFFF"
"LightCyan #E0FFFF"
"PaleTurquoise #AFEEEE"
"Aquamarine #7FFFD4"
"Turquoise #40E0D0"
"MediumTurquoise #48D1CC"
"DarkTurquoise #00CED1"
"CadetBlue #5F9EA0"
"SteelBlue #4682B4"
"LightSteelBlue #B0C4DE"
"PowderBlue #B0E0E6"
"LightBlue #ADD8E6"
"SkyBlue #87CEEB"
"LightSkyBlue #87CEFA"
"DeepSkyBlue #00BFFF"
"DodgerBlue #1E90FF"
"CornflowerBlue #6495ED"
"MediumSlateBlue #7B68EE"
"RoyalBlue #4169E1"
"Blue #0000FF"
"MediumBlue #0000CD"
"DarkBlue #00008B"
"Navy #000080"
"MidnightBlue #191970"
)
# browns
browns=(
"Cornsilk #FFF8DC"
"BlanchedAlmond #FFEBCD"
"Bisque #FFE4C4"
"NavajoWhite #FFDEAD"
"Wheat #F5DEB3"
"BurlyWood #DEB887"
"Tan #D2B48C"
"RosyBrown #BC8F8F"
"SandyBrown #F4A460"
"Goldenrod #DAA520"
"DarkGoldenrod #B8860B"
"Peru #CD853F"
"Chocolate #D2691E"
"SaddleBrown #8B4513"
"Sienna #A0522D"
"Brown #A52A2A"
"Maroon #800000"
)
# whites
whites=(
"White #FFFFFF"
"Snow #FFFAFA"
"HoneyDew #F0FFF0"
"MintCream #F5FFFA"
"Azure #F0FFFF"
"AliceBlue #F0F8FF"
"GhostWhite #F8F8FF"
"WhiteSmoke #F5F5F5"
"SeaShell #FFF5EE"
"Beige #F5F5DC"
"OldLace #FDF5E6"
"FloralWhite #FFFAF0"
"Ivory #FFFFF0"
"AntiqueWhite #FAEBD7"
"Linen #FAF0E6"
"LavenderBlush #FFF0F5"
"MistyRose #FFE4E1"
)
# grays
grays=(
"Gainsboro #DCDCDC"
"LightGray #D3D3D3"
"Silver #C0C0C0"
"DarkGray #A9A9A9"
"Gray #808080"
"DimGray #696969"
"LightSlateGray #778899"
"SlateGray #708090"
"DarkSlateGray #2F4F4F"
"Black #000000"
)
colors=(
"${reds[@]}"
"${pinks[@]}"
"${oranges[@]}"
"${yellows[@]}"
"${purples[@]}"
"${greens[@]}"
"${blues_and_cyans[@]}"
"${browns[@]}"
"${whites[@]}"
"${grays[@]}"
)
# Color generation logic
number_of_colors=${#colors[@]}
number_of_lines=$(wc -l < "colors.sh" 2>/dev/null || echo 0)
# Generate ANSI codes for all colors
for color_data in "${colors[@]}"; do
IFS=$' ' read -r color_name hex_code <<< "$color_data"
hexToAnsiColors "$color_name" "$hex_code"
done
# Write the collected foreground and background colors into the colors.sh file
{
for fg in "${fg_colors[@]}"; do
echo "$fg"
done
for bg in "${bg_colors[@]}"; do
echo "$bg"
done
} >> colors.sh
# Load colors.sh
source colors.sh
squid=๐Ÿ™
robot=๐Ÿค–
unicorn=๐Ÿฆ„
fox=๐ŸฆŠ
lion=๐Ÿฆ
monkey=๐Ÿต
chicken=๐Ÿ”
panda=๐Ÿผ
whale=๐Ÿณ
dog=๐Ÿถ
cat=๐Ÿฑ
cow=๐Ÿฎ
hamster=๐Ÿน
rabbit=๐Ÿฐ
dragon=๐Ÿฒ
fire=๐Ÿ”ฅ
bomb=๐Ÿ’ฃ
game=๐Ÿ•น๏ธ
pad=๐ŸŽฎ
memo=๐Ÿ“
wrench=๐Ÿ› 
disk=๐Ÿ’พ
wave=๐Ÿ‘‹
screen=๐Ÿ–ฅ๏ธ
file=๐Ÿ—„๏ธ
clamp=๐Ÿ—œ๏ธ
checked=โ—‰
unecheked=โ—‹
failed=โฆป
hourglass=โณ
barchart=๐Ÿ“Š
rocket=๐Ÿš€
satelite=๐Ÿ“ก
swim=๐ŸŠ๐Ÿฝโ€โ™‚๏ธ
pager=๐Ÿ“Ÿ
lockwithkey=๐Ÿ”
hide="\033[?25l"
show="\033[?25h"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment