dotfiles/bin/gradient

29 lines
587 B
Text
Raw Normal View History

2022-08-26 18:46:11 -05:00
#!/usr/bin/env bash
2022-08-30 23:09:48 -05:00
# ensure COLUMNS is set
stty size > /dev/null
# delay for wezterm to learn it's size
sleep 0.2
2022-08-26 18:46:11 -05:00
line() {
i=1
2022-08-30 23:09:48 -05:00
while [[ $i -le $COLUMNS ]]; do
echo -en "\u258$((RANDOM % 8 + 1))"
i=$((i + 1))
2022-08-26 18:46:11 -05:00
done
}
2022-08-30 23:09:48 -05:00
awk -v columns="$COLUMNS" -v s="$(line)" \
2022-08-26 18:46:11 -05:00
'BEGIN{
for (colnum = 0; colnum<columns+1; colnum++) {
r = 255-(colnum*255/columns);
g = (colnum*510/columns);
b = (colnum*255/columns);
if (g>255) g = 510-g;
printf "\033[38;2;%d;%d;%dm", r,g,b;
printf "%s\033[0m", substr(s,colnum+1,1);
}
printf "\n";
}'