Skip to content

Instantly share code, notes, and snippets.

@adsr
Created September 21, 2025 19:50
Show Gist options
  • Select an option

  • Save adsr/86219ec4cb9176854349d930534995aa to your computer and use it in GitHub Desktop.

Select an option

Save adsr/86219ec4cb9176854349d930534995aa to your computer and use it in GitHub Desktop.
#!/bin/awk -f
NR==1 { if ($0 != "P3") exit(1); if (!c) c="@"; next }
/^#/ { next }
w==0 { w=$1; h=$2; next }
m==0 { m=$1; r=-1; g=-1; next }
r==-1 { r=$1; next }
g==-1 { g=$1; next }
g!=-1 {
printf("\x1b[38;2;%d;%d;%dm%s", r, g, $1, c);
if (++i==w) { printf("\n"); i=0 }
r=g=-1
}
END { printf("\x1b[0") }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment