def _join_codes(fg, bg):
    """Join `fg` and `bg` with ; and surround with correct esc sequence."""
    colors = ';'.join(filter(lambda c: len(c) > 0, (fg, bg)))
    if colors:
        return '\x1b[' + colors + 'm'

    return ''