Skip to content

Instantly share code, notes, and snippets.

@MatthewLymer
Last active May 6, 2026 19:57
Show Gist options
  • Select an option

  • Save MatthewLymer/9e328942838534c76eb3cadd477bc75a to your computer and use it in GitHub Desktop.

Select an option

Save MatthewLymer/9e328942838534c76eb3cadd477bc75a to your computer and use it in GitHub Desktop.
Bash Gradient
width=80
echo 'Truecolor gradient:'
for ((i=0; i<width; i++)); do
r=$((255 * i / width))
b=$(( 255 * (width - i) / width ))
mid=$((2 * i - width))
if ((mid < 0)); then mid=$((-mid)); fi
g=$(( 255 * (width - mid) / width ))
printf '\033[48;2;%d;%d;%dm ' "$r" "$g" "$b"
done
printf '\033[0m\n'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment