Skip to content

Instantly share code, notes, and snippets.

@gibatronic
Created October 1, 2015 12:45
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 gibatronic/d0382d21444cdee56d37 to your computer and use it in GitHub Desktop.
Save gibatronic/d0382d21444cdee56d37 to your computer and use it in GitHub Desktop.
RGB shell color
# usage
./color <r> <g> <b>
#!/usr/bin/env python
# coding: utf-8
import sys
def c(c):
return round(max(0, min(255, int(c))) / 255 * 5)
def rgb(r, g, b):
return 16 + (36 * c(r)) + (6 * c(g)) + c(b)
c = rgb(*sys.argv[1:])
print('')
print(' \x1B[38;5;%dm█\x1B[0m \\x1B[38;5;%dm' % (c, c))
print('')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment