Created
July 11, 2025 03:42
-
-
Save gesslar/d3db913a1141ed2b636ad5fdcc4c90e3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Setup the 256 colour variables | |
# 256 Color Functions | |
# Source this from your .bashrc | |
# Copyright: nope | |
# Warranty: heh | |
# License: The Unlicense -https://choosealicense.com/licenses/unlicense/ | |
# - With love from gesslar and Claude 🥰 - 2025 | |
# | |
# Usage examples: | |
# echo "$(F_219)This is foreground color 219$(RST)" | |
# echo "$(B_196)This is bright red background$(RST)" | |
# echo "$(F_046)$(B_196)Green text on red background$(RST)" | |
# Generate all 256 foreground and background color functions | |
for i in {0..255}; do | |
# Create foreground functions F_000 through F_255 | |
eval "F_$(printf "%03d" $i)() { echo -ne '\033[38;5;${i}m'; }" | |
# Create background functions B_000 through B_255 | |
eval "B_$(printf "%03d" $i)() { echo -ne '\033[48;5;${i}m'; }" | |
done | |
# Reset function | |
RST() { echo -ne '\033[0m'; } | |
# Optional: Create some common aliases for frequently used colors | |
# (These override the numbered versions for convenience) | |
F_RED() { echo -ne '\033[38;5;196m'; } # Bright red | |
F_GREEN() { echo -ne '\033[38;5;46m'; } # Bright green | |
F_YELLOW() { echo -ne '\033[38;5;226m'; } # Bright yellow | |
F_BLUE() { echo -ne '\033[38;5;39m'; } # Bright blue | |
F_CYAN() { echo -ne '\033[38;5;51m'; } # Bright cyan | |
F_MAGENTA() { echo -ne '\033[38;5;207m'; } # Bright magenta | |
# Export all the color functions so subshells can use them | |
export -f RST | |
for i in {0..255}; do | |
export -f F_$(printf "%03d" $i) | |
export -f B_$(printf "%03d" $i) | |
done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# 256 Colors Display Script - Grid Layout | |
# Clean grid with actual color numbers. Use them | |
# Copyright: nope | |
# Warranty: heh | |
# License: The Unlicense -https://choosealicense.com/licenses/unlicense/ | |
# - With love from gesslar and Claude 🥰 - 2025 | |
# | |
# Usage examples: | |
# echo "$(F_219)This is foreground color 219$(RST)" | |
# echo "$(B_196)This is bright red background$(RST)" | |
# echo "$(F_046)$(B_196)Green text on red background$(RST)" | |
# Reset function | |
RST() { echo -ne '\033[0m'; } | |
# Foreground color function | |
F() { echo -ne "\033[38;5;${1}m"; } | |
# Background color function | |
B() { echo -ne "\033[48;5;${1}m"; } | |
echo -e " $(F_227)-= $(F_198)High Color List $(F_227)=-$(RST)" | |
echo | |
# Rainbow colors (16-231) - 3 sections, 6 rows each, 12 colors per row | |
for i in {0..2}; do | |
for j in {0..5}; do | |
for k in {0..11}; do | |
color=$((16 + i * (6 * 12) + j + k * 6)) | |
printf "$(F $color)%03d$(RST) " "$color" | |
done | |
echo | |
done | |
done | |
echo | |
# Grayscale (232-255) - 2 rows, 12 colors each | |
for i in {0..1}; do | |
for j in {0..11}; do | |
color=$((232 + i * 12 + j)) | |
printf "$(F $color)%03d$(RST) " "$color" | |
done | |
echo | |
done | |
echo | |
# Base colors (0-15) - 2 rows, 8 colors each | |
for i in {0..1}; do | |
for j in {0..7}; do | |
color=$((i * 8 + j)) | |
printf "$(F $color)%03d$(RST) " "$color" | |
done | |
echo | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment