irongit

a bin full of cool programs

hygobin/bin/random_style
15 lines723 B
1#!/bin/bash
2
3# Arrays for text styles, colors, and backgrounds
4STYLES=("0" "1" "3" "4" "7") # Reset, Bold, Italic, Underline, Reversed
5TEXT_COLORS=("30" "31" "32" "33" "34" "35" "36" "37") # Black to White
6BG_COLORS=("40" "41" "42" "43" "44" "45" "46" "47") # Background colors
7
8# Select random values from arrays
9RANDOM_STYLE=${STYLES[$RANDOM % ${#STYLES[@]}]}
10RANDOM_TEXT_COLOR=${TEXT_COLORS[$RANDOM % ${#TEXT_COLORS[@]}]}
11RANDOM_BG_COLOR=${BG_COLORS[$RANDOM % ${#BG_COLORS[@]}]}
12
13# Display the random style
14echo "Your random \\e style: \\e[${RANDOM_STYLE};${RANDOM_TEXT_COLOR};${RANDOM_BG_COLOR}m"
15echo -e "\\e[${RANDOM_STYLE};${RANDOM_TEXT_COLOR};${RANDOM_BG_COLOR}mThis is a test text with the generated style!\\e[0m"