Skip to content

Instantly share code, notes, and snippets.

@dlqs
Last active May 5, 2021 10:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dlqs/cfaf6bec0dd8b32e2e4e83ab4e16ea54 to your computer and use it in GitHub Desktop.
Save dlqs/cfaf6bec0dd8b32e2e4e83ab4e16ea54 to your computer and use it in GitHub Desktop.
Awk script to colorize text in a rainbow, a la lolcat
#!/bin/awk -f
BEGIN{
srand();
s=int(rand()*10);
} {
c=128;
w=127;
f=0.1;
for (i=1; i<=length($0); i+=1) {
v=s+f*(i+2*NR);
r=sin(v)*w+c;
g=sin(v+2.094)*w+c;
b=sin(v+4.188)*w+c;
printf "\x1b[38;2;%d;%d;%dm%s", r, g, b, substr($0, i, 1);
}
printf "\x1b[0m\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment