dotfiles/bin/gradient

30 lines
622 B
Text
Raw Normal View History

2022-08-26 18:46:11 -05:00
#!/usr/bin/env bash
2022-09-06 23:22:38 -05:00
sleep 0.2 # let wezterm catch up
2022-09-02 15:57:52 -05:00
COLUMNS=$(tput cols)
2022-08-26 18:46:11 -05:00
line() {
2022-09-06 23:22:38 -05:00
i=1
while [[ $i -le $COLUMNS ]]; do
echo -en "\U1FB$((RANDOM % 3))$((RANDOM % 8+1))"
i=$((i + 1))
done
2022-08-26 18:46:11 -05:00
}
2022-09-06 23:22:38 -05:00
print-line() {
awk -v columns="$COLUMNS" -v s="$(line)" \
'BEGIN{
for (colnum = 0; colnum<columns+1; colnum++) {
2022-08-26 18:46:11 -05:00
r = 255-(colnum*255/columns);
g = (colnum*510/columns);
b = (colnum*255/columns);
if (g>255) g = 510-g;
2022-09-06 23:22:38 -05:00
printf "\033[38;2;%d;%d;%d;49m", r,g,b;
2022-08-26 18:46:11 -05:00
printf "%s\033[0m", substr(s,colnum+1,1);
2022-09-06 23:22:38 -05:00
}
printf "\n";
}'
}
print-line
print-line