Returns the forground color terminal escape sequence for the given color code number or color name.

def fgseq(code):
    """
    Returns the forground color terminal escape sequence for the given color code number or color name.
    """
    if isinstance(code, str):
        code = nametonum(code)
    
    if code == -1:
        return ""
    
    s = termcap.get('setaf', code) or termcap.get('setf', code)
    return s