def _detect_term_type():
        """
        Detect the type of the terminal.
        """
        if os.name == 'nt':
            if os.environ.get('TERM') == 'xterm':
                # maybe MinTTY
                return 'mintty'
            else:
                return 'nt'
        if platform.system().upper().startswith('CYGWIN'):
            return 'cygwin'
        return 'posix'
Detect the type of the terminal.