#!/usr/bin/env python
light_colors = range(9, 16)
dark_colors = range(0, 9)
acceptable_colors = light_colors + dark_colors

def _hash(what):
   return acceptable_colors[hash(str(what)) % len(acceptable_colors)]

if __name__ == '__main__':
    import socket
    import sys
    import getpass

    username = getpass.getuser()
    hostname = socket.gethostname()
    hashstr = '{}@{}'.format(username, hostname)

    bg = _hash(hashstr)
    if bg in dark_colors:
        fg = 254
    else:
        fg = 0

    if '--bg-color-only' in sys.argv:
        print 'colour{}'.format(bg)
    elif '--fg-color-only' in sys.argv:
        print 'colour{}'.format(fg)
    else:
        print '#[fg=colour{},bg=colour{}]'.format(fg, bg)
