Get the terminal size in width and height. Works on Linux, Mac OS X, Windows, Cygwin (Windows).

    :return: Returns a 2-tuple with width and height.

def get_terminal_size():
    """
    Get the terminal size in width and height. Works on Linux, Mac OS X, Windows, Cygwin (Windows).

    :return: Returns a 2-tuple with width and height.
    """
    import platform
   
    current_os = platform.system()
    tuple_xy = None
    if current_os == 'Windows':
        tuple_xy = get_windows_terminal_size()
        if tuple_xy is None:
            tuple_xy = get_unix_tput_terminal_size()  # needed for window's python in cygwin's xterm!
    elif current_os == 'Linux' or current_os == 'Darwin' or current_os.startswith('CYGWIN'):
        tuple_xy = get_unix_ioctl_terminal_size()

    if tuple_xy is None:
        tuple_xy = (80, 25)  # default value
    return tuple_xy