Skip to content

Instantly share code, notes, and snippets.

@ilansmith
Created August 19, 2017 11:24
Show Gist options
  • Save ilansmith/313039c3b5493e2c745b559a958bd939 to your computer and use it in GitHub Desktop.
Save ilansmith/313039c3b5493e2c745b559a958bd939 to your computer and use it in GitHub Desktop.
Shell Colours
#include <stdio.h>
#define CLEAR "\033[00;00;00m"
static void p_colour(int c1, int c2)
{
char col[10];
sprintf(col, "\033[%d;%dm", c1, c2);
printf("\"\\033[%d;%dm\" = %scolour%s\n", c1, c2, col, CLEAR);
fflush(stdout);
}
static void test(void)
{
#define COL_BLINK "\033[00;05m"
#define COL_RED "\033[01;29;41m"
printf("%s%s_%s\n", COL_BLINK, COL_RED, CLEAR);
fflush(stdout);
}
int main(int argc, char *argv[])
{
int i, j;
for (i = 0; i < 9; i++) {
for (j = 0; j < 80; j++)
p_colour(i, j);
}
test();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment