Skip to content

Instantly share code, notes, and snippets.

@pmsanford
Created November 6, 2014 19:16
Show Gist options
  • Save pmsanford/13767a160a460edbf66b to your computer and use it in GitHub Desktop.
Save pmsanford/13767a160a460edbf66b to your computer and use it in GitHub Desktop.
A small python file to display all curses-supported colors on your terminal.
import curses
def main(stdscr):
curses.start_color()
curses.use_default_colors()
for i in range(0, curses.COLORS):
curses.init_pair(i+1, i, -1)
colorno = 0
fmt = '{0:3}: color'
fmtlen = len(fmt.format(0)) + 1
while colorno < 256:
line = 0
for i in range(0, int(curses.COLS / fmtlen)):
for j in range(0, curses.LINES):
stdscr.addstr(j, i * fmtlen, fmt.format(str(colorno-1)), curses.color_pair(colorno))
colorno += 1
stdscr.getkey()
curses.wrapper(main)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment