#!/usr/bin/env python

import sys
import re
from subprocess import call

aliases = {
        'll+a+': 'ls -l -a --color',
        '.*?list.*files.*please.?': 'ls --color'
        }

filetypes = {
        '.+\.html': 'chromium-browser'
        }

command_found = False
for alias, command in aliases.items():
    if re.match(alias, sys.argv[1]):
        args = ' '.join(command.split() + sys.argv[2:])
        call(args, shell=True)
        command_found = True
        break

if not command_found:
    for filetype, command in filetypes.items():
        if re.match(filetype, sys.argv[1]):
            call([command, filetype], shell=True)
            command_found = True
            break

if not command_found:
    print '{}: Command not found'.format(sys.argv[1])
