#!/usr/bin/env python

def xterm_color(string, color):
    colors = {'none': "0",
              'black': "0;30",
              'red': "0;31",
              'green': "0;32",
              'brown': "0;33",
              'blue': "0;34",
              'purple': "0;35",
              'cyan': "0;36",
              'light-gray': "0;37",
              'dark-gray': "1:30",
              'light-red': "1;31",
              'light-green': "1;32",
              'yellow': "1;33",
              'light-blue': "1;34",
              'light-purple': "1;35",
              'light-cyan': "1;36",
              'white': "1;37"}
    return "\033[%sm%s\033[0m" % (colors[color], string)

def noColors():
    return False

def isXterm():
    return True

def colorize(string, color):
    if noColors():
        return string
    if isXterm():
        return xterm_color(string, color)
    return string

def replaceQuotes(stuff):
    import re
    return re.sub(r'"', r'\\"', stuff)

import sys, subprocess, time
print "%s %s" % ("%s%s%s" % (colorize("[", 'light-red'), colorize(time.strftime("%H:%M:%S"), 'light-gray'), colorize("]", 'light-red')), ' '.join(sys.argv[1:]))
sys.exit(subprocess.call([replaceQuotes(' '.join(sys.argv[1:]))], shell = True))
